[Python-ideas] raw strings

Clark Maurer cmaurer at slickedit.com
Mon Oct 1 23:13:23 CEST 2007

Guido, I'm not proposing both escape mechanisms.  Quote-doubling is a
mechanism which should be used ONLY for raw strings. Let be very
specific how this is done:

  r"Here's a string with a single quote"
  r'"Heres a double quoted string"'
  r'["'']'  # This regex has both quotes in it
  r"[""']"  # This regex has both quotes in it

Quote doubling is only for the quote you started the raw string with.
This would be consistent with C#, REXX, and Slick-C. It sounds like
you've never used a language with this construct. It's very natural to
me. This would make the raw strings implementation complete.

-----Original Message-----
From: gvanrossum at gmail.com [mailto:gvanrossum at gmail.com] On Behalf Of
Guido van Rossum
Sent: Monday, October 01, 2007 4:40 PM
To: Clark Maurer
Cc: Python-Ideas
Subject: Re: [Python-ideas] raw strings

(Clark: I don't want to discuss this offline. On the list it goes.)

Quote doubling isn't a viable option for Python -- I don't believe
it's sane to have both backslashes and quote-double as escape

Of course in C# the trailing \ is the main use case -- after all it's
a Microsoft product.

While for some Windows users this may be a nuisance, I don't think
they are in the majority amongst Python users.


On 10/1/07, Clark Maurer <cmaurer at slickedit.com> wrote:
> I'll do what I can to sway you.
> Guido, please....pretty please with sugar on top (hehehe). I've been
> spoiled with languages which do better raw string. I designed Slick-C
> which I've been using for years and it does not have this problem. I
> always type Windows paths using the Slick-C equivalent of raw strings.
> My implementation came from REXX (I'm no spring chicken- I think
> heard of it too :-). Now that C# has gone with this implementation,
> pretty much makes it the modern way to do this. C# has a lot more
> than Slick-C. Yes, these style strings are intended for regexes AND
> Windows paths. Just think, you can get rid of one FAQ. It's easier to
> document. The down side is that there will be some backward
> compatibility issues. I will admit, compared to other issues this is a
> small one.
> Trailing backslash isn't the only problem but it's the bigger one. Two
> quotes should be one single quote. Otherwise, specifying both quote
> characters in regexes is an issue. Yes, I've done this in regular
> expressions. This change could cause some backward compatibility
> problems as well.
> Clark
> -----Original Message-----
> From: python-ideas-bounces at python.org
> [mailto:python-ideas-bounces at python.org] On Behalf Of Guido van Rossum
> Sent: Monday, October 01, 2007 3:54 PM
> To: Steven Bethard
> Cc: Python-Ideas
> Subject: Re: [Python-ideas] raw strings
> On 10/1/07, Steven Bethard <steven.bethard at gmail.com> wrote:
> > > On 10/1/07, Steven Bethard <steven.bethard at gmail.com> wrote:
> > > > On 10/1/07, Clark Maurer <cmaurer at slickedit.com> wrote:
> > > > > The current implementation doesn't allow for a trailing
> backslash in the
> > > > > string.
> > > >
> > > > I believe that will change in Python 3.0.
> > > >
> > > > The discussion is here:
> > > >
> > > >
> > > > And Ron Adam's current patch is here:
> > > > http://bugs.python.org/issue1720390
> >
> > On 10/1/07, Guido van Rossum <guido at python.org> wrote:
> > > I'm still against actually. That's why the patch hasn't been
> yet.
> >
> > Sorry, my mistake. I read the thread as being somewhat in support of
> the change.
> I admit I've been wobbling a lot on this.
> > Anyway, to the OP, if you want to make this happen, you should help
> > Ron out with his patch.  (Code has a much better chance of
> > Guido than anything else does.)
> Not in this case. It's more the philosophical distinction -- are raw
> strings meant primarily to hold regexes or Windows pathnames? These
> two use cases have opposite requirements for trailing backslash
> treatment. I know the original use case that caused them to be added
> to the language is regexes, and that's still the only one I use on a
> regular basis.
> --
> --Guido van Rossum (home page: http://www.python.org/~guido/)
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-ideas mailing list