[Python-ideas] raw strings
cmaurer at slickedit.com
Mon Oct 1 16:11:39 CEST 2007
I'll apologize in advance for this one since I suspect a lot of people
have hit this.
The current implementation doesn't allow for a trailing backslash in the
Why don't raw strings in Python work more like C# @"..." strings? Then
it would allow for a trailing backslash and you could still get a single
quote by two consecutive quotes characters.
f=r'c:\src\f' # This is ok and gives you what you want
f=r'c:\src\f\' # Compilation error. String is not terminated.
f=r'''c:\src\f\''' # This doesn't work either and causes a compilation
f=r'Here''s another mistake' # This doesn't do what you would think.
# You get
'Heres another mistake'
f=r'''Here's another mistake''' # This works but being able to use raw
strings for this would be nice.
f='c:\\src\\f\\' # this works but is ugly
I just don't understand the rationale for the current implementation.
I thought the intention of raw strings was to allow for backslashes in
the string. The current implementation does a bad job at it. Any
chance this could be changed with a backward compatibility option?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas