what is wrong with that r"\"
horpner at yahoo.com
Wed Jul 4 13:21:14 CEST 2007
On 2007-07-04, Nick Craig-Wood <nick at craig-wood.com> wrote:
>> String quotes can be escaped with a backslash, but the
>> backslash remains in the string; for example, r"\"" is a
>> valid string literal consisting of two characters: a
>> backslash and a double quote;
> a) That is weird! Why would you ever want to do that - ie
> insert \" into your string as a special case? If I wanted a "
> in a raw string then I'd use a r'' string or a triple quoted
> If we removed a) then we could remove b) also and r"" strings
> would work as everyone expects.
> Does anyone know the justification for a)? Maybe we should
> remove it in py3k?
If the escaped quotes didn't function in raw strings, I'd be
unable to construct (with a single notation) a regex that
included both kinds of quotes at once.
More information about the Python-list