r'\' - python parser bug?
Tim Peters
tim.one at comcast.net
Mon May 24 10:53:24 EDT 2004
[Konstantin Veretennicov]
> ActivePython 2.3.2 Build 232
> >>> '\\'
> '\\'
> >>> r'\'
> File "<stdin>", line 1
> r'\'
> ^
> SyntaxError: EOL while scanning single-quoted string
>
> Is this a known issue?
Yes, and a documented one: an r-string cannot end with an odd number of
backslashes. Note that your first expression ('\\') did create a string
with a single backslash, although the repr of that string may have fooled
you into thinking you got two backslashes.
>>> '\\'
'\\'
>>> len('\\')
1
>>> print '\\'
\
>>>
> Should i submit a bug report to development?
Nope: it's not a bug, and won't change.
More information about the Python-list
mailing list