I'm trying to determine if this is intended behavior:

>>> r"\""
'\\"'

>>> r'\''
"\\'"

Normally, the quote would end the string, but it gets escaped by the
preceding '\'. However, the preceding slash is interpreted as 'not a
backslash' because of the raw indicator, so it gets left in verbatim.

Note that it works anywhere:

>>> r"testing \" backslash and quote"
'testing \\" backslash and quote'

It happens that this is the behavior I want, but it seemed just as
likely to be an error. I tested it with python2.5 and 2.6 and got the
same results.

Is this something I can count on? Or is it undefined behavior and I
should really not be doing it?

John
=:->
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to