[Python-3000] Escaping in raw strings (was Re: [Python-Dev] PEP 30XZ: Simplified Parsing)
g.brandl at gmx.net
Thu May 3 15:50:07 CEST 2007
Benji York schrieb:
> Ron Adam wrote:
>> The following inconsistency still bothers me, but I suppose it's an edge
>> case that doesn't cause problems.
>> >>> print r"hello world\"
>> File "<stdin>", line 1
>> print r"hello world\"
>> SyntaxError: EOL while scanning single-quoted string
>> In the first case, it's treated as a continuation character even though
>> it's not at the end of a physical line. So it gives an error.
> No, that is unrelated to line continuation. The \" is an escape
> sequence, therefore there is no double-quote to end the string literal.
But IMHO this is really something that can and ought to be fixed.
I would let a raw string end at the first matching quote and not have any
escaping available. That's no loss of functionality since there is no
way to put a single " into a r"" string today. You can do r"\"", but it
doesn't have the effect of just escaping the closing quote, so it's
Is that something that can be agreed upon without a PEP?
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.
More information about the Python-3000