r'\' - python parser bug?
Tim Peters
tim.one at comcast.net
Tue May 25 11:25:09 EDT 2004
[Tim Peters]
>> Yup. Right now all tools (including Python itself) that scan over
>> strings in Python source can (and usually do) treat backslashes
>> identically, whether in loops or in regexps.
[</F>]
> Or in other words, the point here is that the prefix flag (u, r,
> whatever) doesn't affect how a string literal is *parsed*. When the
> parser sees a backslash inside a string literal, it always skips the
> next character. There's no separate grammar for "raw string literals".
Indeed, and that's a helpful amplification. Let's also amplify "the parser"
to "a large number of distinct parsers, in a large number of programs that
parse Python source". If it was only the Python compiler's parser that
needed to change, it wouldn't be a *nightmare* to change (although Guido
would still reject changing it).
More information about the Python-list
mailing list