[Python-ideas] raw strings

Guido van Rossum guido at python.org
Mon Oct 1 23:30:02 CEST 2007

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.

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

More information about the Python-ideas mailing list