R. David Murray rdmur...@bitdance.com added the comment:
Well, the problem with the reference is that the language reference is intended
as a specification document, not a tutorial, so such a discussion does not
belong there. The library reference, which does contain platform-specific and
Graham Wideman initcont...@grahamwideman.com added the comment:
Thanks to all for your patient comments. I think I am resigned to raw-string
forever being medium-rare-string :-).
Perhaps it's obvious once you get over the initial shock of non-rawness, but
workarounds for the disallowed
R. David Murray rdmur...@bitdance.com added the comment:
I've opened issue 11479 with a proposed patch to the tutorial along the lines
suggested by Graham.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1271
Glenn Linderman v+pyt...@g.nevcal.com added the comment:
On 3/12/2011 7:11 PM, R. David Murray wrote:
R. David Murrayrdmur...@bitdance.com added the comment:
I've opened issue 11479 with a proposed patch to the tutorial along the lines
suggested by Graham.
Which is good, for people that
Glenn Linderman v+pyt...@g.nevcal.com added the comment:
I can certainly agree with the opinion that raw strings are working as
documented, but I can also agree with the opinion that they contain traps for
the unwary, and after getting trapped several times, I have chosen to put up
with the
R. David Murray rdmur...@bitdance.com added the comment:
I think perhaps the language in the language reference is a bit misleading.
The purpose of the raw string algorithm is that any characters in the string be
copied literally into the string object. That is, \ escapes the not so
that
Graham Wideman initcont...@grahamwideman.com added the comment:
@Glenn Linderman: I too am usually quick to assume that innocent fixes may
have serious unforeseen impacts, but in this case I'm not convinced. What
would matter is to enumerate the current behavior, and of that what would be
R. David Murray rdmur...@bitdance.com added the comment:
If I'm remembering the discussion I read correctly, what the parser does is to
parse the a regular string and a raw string in exactly the same way, but in the
raw string case, it does not do the subsequent escape sequence replacement
Glenn Linderman v+pyt...@g.nevcal.com added the comment:
@Graham: seems like the two primary gotchas are trailing \ and \ \' not
removing the \. The one that tripped me up the most was the trailing \, but I
did get hit with \ once. Probably if Python had been my first programming
language
R. David Murray rdmur...@bitdance.com added the comment:
Well, it's still the case that the Python raw string syntax isn't going to
change to not escape the quotes, because that would break far too many existing
applications that depend on them being escaped. So a new string literal type
Graham Wideman initcont...@grahamwideman.com added the comment:
(Not clear how to reopen this issue. Hopefully my change here does that.)
OK, so as it currently stands, backslash at end of string is prohibited in the
interests of allowing backslash to escape quotes that might be embedded
Changes by Ezio Melotti ezio.melo...@gmail.com:
--
status: closed - open
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1271
___
___
New submission from Tim Gordon:
If you have a raw string with a backslash as the last character, the
parser thinks the following quote, actually used to mark the end of the
string, is being quoted by the backslash. For example, r'\' should be
the string with one backslash, but...
print
Tim Gordon added the comment:
So basically raw strings are useless if you need to end a string with a
backslash, as there is no way to quote the backslash to make it not do
this... This surely can't be too hard to fix if one considers it a
problem (which I do), and just because even the docs
Georg Brandl added the comment:
There's more to allowing \ at the end of a raw string: if you do that,
the raw string will end at the first quote character which is the same
as the opening one, so you can't put such a quote character into a raw
string anymore. At the moment, you can, by escaping
Facundo Batista added the comment:
As stated in the docs...
http://docs.python.org/dev/reference/lexical_analysis.html#string-literals
r\ is not a valid string literal (even a raw string cannot
end in an odd number of backslashes). Specifically, a raw
string cannot end in a single
16 matches
Mail list logo