[issue1271] Raw string parsing fails with backslash as last character

2011-03-13 Thread R. David Murray
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-12 Thread Graham Wideman
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-12 Thread R. David Murray
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-12 Thread Glenn Linderman
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-11 Thread Glenn Linderman
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-11 Thread R. David Murray
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-11 Thread Graham Wideman
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-11 Thread R. David Murray
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-11 Thread Glenn Linderman
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-11 Thread R. David Murray
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-09 Thread Graham Wideman
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

[issue1271] Raw string parsing fails with backslash as last character

2011-03-09 Thread Ezio Melotti
Changes by Ezio Melotti ezio.melo...@gmail.com: -- status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1271 ___ ___

[issue1271] Raw string parsing fails with backslash as last character

2007-10-12 Thread Tim Gordon
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

[issue1271] Raw string parsing fails with backslash as last character

2007-10-12 Thread Tim Gordon
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

[issue1271] Raw string parsing fails with backslash as last character

2007-10-12 Thread Georg Brandl
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

[issue1271] Raw string parsing fails with backslash as last character

2007-10-12 Thread Facundo Batista
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