Simple syntax question

Erik Max Francis max at alcyone.com
Mon May 12 04:50:18 EDT 2003


Duncan Booth wrote:

> A minor nitpick. A backslash does still have a special meaning in a
> raw
> string if it is followed by a quote: then the backslash prevents the
> following quote terminating the string, although the backslash itself
> is
> not removed from the string.
> 
> e.g.
> >>> s = r"\""
> >>> s
> '\\"'

Good point, which is why r'\' (or r"\") as a standalone literal string
is illegal:

>>> r'\'
  File "<stdin>", line 1
    r'\'
       ^
SyntaxError: invalid token


-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ All the people in his neighborhood turn around and get mad and sing
\__/ Public Enemy
    Church / http://www.alcyone.com/pyos/church/
 A lambda calculus explorer in Python.




More information about the Python-list mailing list