String handling bug in Python
Tim Peters
tim.one at comcast.net
Fri Apr 26 18:14:13 EDT 2002
> ...
> What do you do in your scheme if you want a z-string to contain a
> single double-quote?
>
[Bjorn Pettersen]
> I always thought that could be spelled r'"' or r'''"''',
Sure, but note the question is asking about the OP's z-string notation,
which supposedly has no difficulties. You're talking about the r-string
notation.
> but I guess there would still be a problem if you wanted all of ", ',
> ''', and """ in a string.
There is with r-strings, yes.
> I would think that would occur less frequently than \ at the end of a
> string though (especially with windows path names). I feel I must be
> missing something?
The good news is that I also feel that you are <wink>. r-strings were
primarily intended to ease writing regular expressions (which can never end
with an odd number of backslashes), and people using \ in Windows pathnames
are usually missing an obvious alternative (like the forward slash --
Windows API functions couldn't care less which kind of slash you use; and
portable code should avoid any literal slashes via os.path.join()).
More information about the Python-list
mailing list