[Python-ideas] raw strings
rrr at ronadam.com
Tue Oct 2 06:44:29 CEST 2007
Guido van Rossum wrote:
> On 10/1/07, Clark Maurer <cmaurer at 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.
More information about the Python-ideas