String handling bug in Python
Cliff Wells
logiplexsoftware at earthlink.net
Fri Apr 26 17:41:47 EDT 2002
On Fri, 26 Apr 2002 15:23:49 -0600
Bjorn Pettersen wrote:
> > From: Tim Peters [mailto:tim.one at comcast.net]
> >
> > [Stephen Ferg]
> > > ...
> > > I would like to see Python support TRULY raw string
> > literals -- string
> > > literals that are not escaped in any way. Perhaps they
> > could be added
> > > with a prefix of z (for zero escaping?), so that
> > >
> > > z"\" == "\\"
> > > z"\'" == "\\\'"
> >
> > The first one can't be spelled at all with a raw string
> > today. The second one can be, and indeed the same way you
> > spelled it, as r"\'". What do you do in your scheme if you
> > want a z-string to contain a single double-quote?
>
> I always thought that could be spelled r'"' or r'''"''', but I guess
> there would still be a problem if you wanted all of ", ', ''', and """
> in a string. 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?
It seems if you imposed the limitation that the z-string not contain the quote
character used to delimit the string then you could simply use concatenation to
get around that limitation:
z"'" z'"' z'\'
--
Cliff Wells, Software Engineer
Logiplex Corporation (www.logiplex.net)
(503) 978-6726 x308 (800) 735-0555 x308
More information about the Python-list
mailing list