Glenn Linderman <v+pyt...@g.nevcal.com> added the comment:

@Graham: seems like the two primary gotchas are trailing \ and \" \' not 
removing the \.  The one that tripped me up the most was the trailing \, but I 
did get hit with \" once.  Probably if Python had been my first programming 
language that used \ escapes, it wouldn't be such a problem, but since it never 
will be, and because I'm forced to use the others from time to time, still, 
learning yet a different form of "not-quite raw" string just isn't worth my 
time and debug efforts.  When I first saw it, it sounded more useful than 
doubling the \s like I do elsewhere, but after repeated trip-ups with trailing 
\, I decided it wasn't for me.

@R David: Interesting description of the parsing/escaping.  Sounds like that 
makes for a cheap parser, fewer cases to handle.  But there is little that is 
hard about escape-free or exact string parsing: just look for the trailing " ' 
""" or ''' that matches the one at the beginning.  The only thing difficult is 
if you want to escape the quote, but with the rich set of quotes available, it 
is extremely unlikely that you can't find one that you can use, except perhaps 
if you are writing a parser for parsing Python strings, in which case, the 
regular expression that matches any leading quote could be expressed as:

'("|"""|' "'|''')"

Granted that isn't the clearest syntax in the world, but it is also uncommon, 
and can be assigned to a nicely named variable such as matchLeadingQuotationRE 
in one place, and used wherever needed.

Regarding the use of / rather that \ that is true if you are passing file names 
to Windows APIs, but not true if you are passing them to other programs that 
use / as option syntax and \ as path separator (most Windows command line 
utilities).

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1271>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to