is this a Python bug?
effbot at telia.com
Wed Feb 16 18:19:12 CET 2000
Brian Langenberger <brian at brian.cbs.umn.edu> wrote:
> : MZ> Raw strings cannot end with a backslash.
> : They can. But only with an even number of them.
> I'm assuming there's some clever and important reason for this.
> But for the life of me I can't figure out what it is.
> Could someone enlighten me as to the reason? :)
a Python string literal consists of an opening quote, a
sequence of escape codes and plain characters, and an
ending quote, i.e.
open ( escape | character )* close
The "r" prefix doesn't change this; Python still parses the
string as if it were an ordinary string, but stores it differently.
in other words, both "\" and r"\" are parsed as an open quote,
followed by an escaped quote, but no closing quote.
More information about the Python-list