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 mechanisms. 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. --Guido On 10/1/07, Clark Maurer <cmaurer@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 you've heard of it too :-). Now that C# has gone with this implementation, that pretty much makes it the modern way to do this. C# has a lot more clout 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@python.org [mailto:python-ideas-bounces@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@gmail.com> wrote:
On 10/1/07, Clark Maurer <cmaurer@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: http://mail.python.org/pipermail/python-3000/2007-May/007684.html
And Ron Adam's current patch is here: http://bugs.python.org/issue1720390
On 10/1/07, Guido van Rossum <guido@python.org> wrote:
I'm still against actually. That's why the patch hasn't been applied yet.
Sorry, my mistake. I read the thread as being somewhat in support of
On 10/1/07, Steven Bethard <steven.bethard@gmail.com> wrote: 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 convincing 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@python.org http://mail.python.org/mailman/listinfo/python-ideas
-- --Guido van Rossum (home page: http://www.python.org/~guido/)

Guido van Rossum schrieb:
(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 mechanisms.
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.
But why upset them? What is the reason for not allowing trailing backslashes in raw strings, except more code in the tokenizer? Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.

On 10/1/07, Georg Brandl <g.brandl@gmx.net> wrote:
Guido van Rossum schrieb:
(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 mechanisms.
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.
But why upset them? What is the reason for not allowing trailing backslashes in raw strings, except more code in the tokenizer?
Well, everybody else who is tokenizing Python will also have to have more code. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

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 you've heard of it too :-). Now that C# has gone with this implementation,
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. Clark -----Original Message----- From: gvanrossum@gmail.com [mailto:gvanrossum@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 mechanisms. 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. --Guido On 10/1/07, Clark Maurer <cmaurer@slickedit.com> wrote: that
pretty much makes it the modern way to do this. C# has a lot more clout 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@python.org [mailto:python-ideas-bounces@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@gmail.com> wrote:
On 10/1/07, Clark Maurer <cmaurer@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:
http://mail.python.org/pipermail/python-3000/2007-May/007684.html
And Ron Adam's current patch is here: http://bugs.python.org/issue1720390
On 10/1/07, Guido van Rossum <guido@python.org> wrote:
I'm still against actually. That's why the patch hasn't been applied yet.
Sorry, my mistake. I read the thread as being somewhat in support of
On 10/1/07, Steven Bethard <steven.bethard@gmail.com> wrote: 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 convincing 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@python.org http://mail.python.org/mailman/listinfo/python-ideas
-- --Guido van Rossum (home page: http://www.python.org/~guido/)

On 10/1/07, Clark Maurer <cmaurer@slickedit.com> wrote:
Quote doubling is only for the quote you started the raw string with.
Understood.
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.
Even python does this, with %% on format strings -- but it is only natural to someone who already has some experience programming. -jJ

On 10/1/07, Clark Maurer <cmaurer@slickedit.com> wrote:
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.
As long as we're making personal comments, who cares about REXX or Slick-C? How many users do they have? And yes, I've used this for years in Pascal, so I'm well familiar with it. The whole problem is that when using regexes you *do* have to deal with both escape mechanisms (one for the string literal tokenization and one for the re module). And that's unacceptable for me. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

It sounds like nobody likes quote-doubling. Supporting a trailing backslash would alleviate the need for an FAQ item and the typical confusion. Sounds like most agree on that point. Sorry about sounding personal. -----Original Message----- From: gvanrossum@gmail.com [mailto:gvanrossum@gmail.com] On Behalf Of Guido van Rossum Sent: Monday, October 01, 2007 5:30 PM To: Clark Maurer Cc: python-ideas@python.org Subject: Re: [Python-ideas] raw strings On 10/1/07, Clark Maurer <cmaurer@slickedit.com> wrote:
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.
As long as we're making personal comments, who cares about REXX or Slick-C? How many users do they have? And yes, I've used this for years in Pascal, so I'm well familiar with it. The whole problem is that when using regexes you *do* have to deal with both escape mechanisms (one for the string literal tokenization and one for the re module). And that's unacceptable for me. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

Guido van Rossum wrote:
On 10/1/07, Clark Maurer <cmaurer@slickedit.com> wrote:
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.
As long as we're making personal comments, who cares about REXX or Slick-C? How many users do they have? And yes, I've used this for years in Pascal, so I'm well familiar with it. The whole problem is that when using regexes you *do* have to deal with both escape mechanisms (one for the string literal tokenization and one for the re module). And that's unacceptable for me.
With pythons current 4 different ways to quote, I don't think quote doubling is needed. Yes, it's the duel escape mechanisms that makes regexes more complex than it needs to be. Ron

Clark Maurer wrote:
Quote-doubling is a mechanism which should be used ONLY for raw strings.
But there would be two quoting mechanisms in the *language*, and you would have to remember which type of string used which.
This would be consistent with C#, REXX, and Slick-C. It's very natural to me.
But *un*-natural to anyone not familiar with those languages, and confusing to anyone expecting consistency between one kind of string and another within the same language. -- Greg Ewing, Computer Science Dept, +--------------------------------------+ University of Canterbury, | Carpe post meridiem! | Christchurch, New Zealand | (I'm not a morning person.) | greg.ewing@canterbury.ac.nz +--------------------------------------+
participants (6)
-
Clark Maurer
-
Georg Brandl
-
Greg Ewing
-
Guido van Rossum
-
Jim Jewett
-
Ron Adam