A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-July/101839.html below:

[Python-Dev] Intended behavior of backlash in raw strings

[Python-Dev] Intended behavior of backlash in raw strings [Python-Dev] Intended behavior of backlash in raw stringsJohn Arbash Meinel john.arbash.meinel at gmail.com
Tue Jul 13 00:26:03 CEST 2010
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
=:->
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4