On Thu, Mar 12, 2009 at 3:28 PM, Jim Garrison wrote: > OK, I'm curious as to the reasoning behind saying that > > 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. > > which sounds reasonable, but then saying in effect "Oh wait, let's > introduce a special case and make it impossible to have a literal > backslash as the last character of a string without doubling it".
That's not a special case; that's the *opposite* of a special case. > So you have a construct (r'...') whose sole reason for existence > is to ignore escapes, but it REQUIRES an escape mechanism for one > specific case (which comes up frequently in Windows pathnames). The backslash still IS an escape character, it just behaves differently than it does for a non-raw string. > At the very least the "all backslashes are left in the string" quote > from the Lexical Analysis page (rendered in italics no less) needs to > be reworded to include the exception instead of burying this in a > parenthetical side-comment. There is no exception. All backslashes are left in the string. The impossibility of ending a raw string in an unescaped backslash is also rendered in italics. -Miles -- http://mail.python.org/mailman/listinfo/python-list