On Tue, Jul 13, 2010 at 12:26 AM, John Arbash Meinel
<john.arbash.mei...@gmail.com> wrote:
>>>> 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.

The behaviour does appear to be explicitly documented in the language reference:

"""
When an 'r' or 'R' prefix is present, a character following a
backslash is included in the string without change, and all
backslashes are left in the string. For example, the string literal
r"\n" consists of two characters: a backslash and a lowercase 'n'.
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).
"""

Schiavo
Simon
_______________________________________________
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