Raw String Question

Tim Chase python.list at tim.thechases.com
Thu Mar 12 14:32:27 EDT 2009


>   >>> r"a\"
>   SyntaxError: EOL while scanning string literal (<pyshell#45>, line 1)
> 
> It seems the parser is interpreting the backslash as an escape
> character in a raw string if the backslash is the last character.
> Is this expected?

Yep...as documented[1], "even a raw string cannot end in an odd 
number of backslashes".

-tkc


[1]
http://docs.python.org/reference/lexical_analysis.html







More information about the Python-list mailing list