Unrecognized escape sequences in string literals
darkwater42 at gmail.com
Tue Aug 11 23:48:24 CEST 2009
On Aug 11, 4:38 pm, Ethan Furman <et... at stoneleaf.us> wrote:
> Mind you, I'm not really vested in how Python *should* handle
> backslashes one way or the other, but I am glad it has rules that it
> follows for consitent results, and I don't have to break out a byte-code
> editor to find out what's in my string literal.
I don't understand your comment. C++ generates a warning if you use an
undefined escape sequence, which indicates that your program should be
fixed. If the escape sequence isn't undefined, then C++ does the same
thing as Python.
It would be *even* better if C++ generated a fatal error in this
situation. (g++ probably has an option to make warnings fatal, but I
don't happen to know what that option is.) g++ might not generate an
error so that you can compile legacy C code with it.
In any case, my argument has consistently been that Python should have
treated undefined escape sequences consistently as fatal errors, not
More information about the Python-list