Best Practice Question

Albert Hopkins marduk at letterboxes.org
Tue Feb 5 09:50:05 EST 2013


[...]
> By the way, did someone ever notice that r'\' fails ? I'm sure there's a
> reason for that... (python 2.5) Anyone knows ?
> 
> r'\'
> SyntaxError: EOL while scanning single-quoted string
> 
>
"Even in a raw string, string quotes can be escaped with a backslash,
but the backslash remains in the string; for example, r"\"" is a valid
string literal consisting of two characters: a backslash and a double
quote; 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 backslash (since the backslash would escape the following
quote character). " -- python docs



More information about the Python-list mailing list