Re: Re[2]: backslashes and r-strings r"abc"

Greg Ewing <[email protected]> Fri, 30 Jul 2004 14:52:50 +1200
Newsgroups gmane.comp.lang.prothon.user
Message-ID <[email protected]>
> Backslashes are not removed in raw strings. So a backslash-quote gives you
> that, a backslash-quote. Hardly useful for including double quotes in a
> single quoted string or vice versa.

You're right, it's not very useful. I hadn't considered that.

So it looks like the best thing is just to not treat
backslashes in any special way at all in an r-string.

Mark Hahn <[email protected]>:

> What in the hell was Guido thinking?

I think it's a result of just doing whatever was easiest to
implement. Python scans Raw strings using the same regular
expression as normal strings, and the post-processing
step which interprets \n etc. is omitted.

If you're willing to scan raw strings using a different
RE, the problem is easily avoided.

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