RE: backslashes and r-strings r"abc"

Greg Ewing <[email protected]> Tue, 27 Jul 2004 14:15:29 +1200
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
Mark Hahn <[email protected]>:

> Does anyone see any reason to preserve Python's restriction on not
> having a backslash as the last character of a r-string?

The reason it's there is because, even inside r-strings, backslashes
still escape quote characters. To remove it, you'd have to either
disallow quotes embedded in r-strings, or come up with some other way
of flagging them without compromising the rawness quality of
r-strings.

>	r"c:\windows directory\"  # throws Python exception

Maybe you could have w-strings for Windows pathnames, that would be
*required* to end in a backslash... :-)

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
[email protected]	   +--------------------------------------+