Unrecognized escape sequences in string literals
steve at REMOVE-THIS-cybersource.com.au
Mon Aug 10 02:06:18 CEST 2009
On Sun, 09 Aug 2009 12:26:54 -0700, Douglas Alan wrote:
> A friend of mine is just learning Python, and he's a bit tweaked about
> how unrecognized escape sequences are treated in Python.
> In any case, I think my friend should mellow out a bit, but we both
> consider this something of a wart. He's just more wart-phobic than I am.
> Is there any way that this behavior can be considered anything other
> than a wart? Other than the unconvincing claim that you can use this
> "feature" to save you a bit of typing sometimes when you actually want a
> backslash to be in your string?
I'd put it this way: a backslash is just an ordinary character, except
when it needs to be special. So Python's behaviour is "treat backslash as
a normal character, except for these exceptions" while the behaviour your
friend wants is "treat a backslash as an error, except for these
Why should a backslash in a string literal be an error?
More information about the Python-list