RE: Re[2]: backslashes and r-strings r"abc"
"Michael Geary" <[email protected]> Mon, 26 Jul 2004 22:39:01 -0700
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <[email protected]> |
> From: Lenard Lindstrom
> Backslash for line continuation in a raw string is
> broken for both Prothon and Python anyways:
>
> Python 2.4a1 (#54, Jul 8 2004, 11:30:13) [MSC v.1310 32 bit
> (Intel)] on win32 Type "help", "copyright", "credits" or
> "license" for more information.
> >>> r"abc\
> ... def"
> 'abc\\\ndef'
By "broken" do you mean "not working according to the spec" or "I don't like
what it does"?
This is working as specified: The backslash escapes the next character so it
does nothing special, and both the backslash and the next character remain
in the string. The resulting string here consists of "abc", backslash,
newline, and "def", as it is supposed to.
> From: Mark Hahn
> How can a backslash do continuation if backslashes are
> disabled in a r-string?
Because backslashes *aren't* disabled in an r-string. They still do
something special, just different from a normal string.
> I would think disallowing them would be ok since we already
> have the single quotes in double quotes etc. method and
> concatenating strings. Combining the two features you can
> create any possible string while using no escaped quotes.
>
> r'a double(") ' r"and a single(') in one r-string with no esc"
>
> Does anyone have a problem with me removing escaped quotes
> from r-strings for completeness and consistency?
Wouldn't bother me. I think everybody gets confused by the way Python
r-strings work. We all think they are "raw" strings when they aren't.
-Mike