[Python-Dev] String literals escape sequences

orbitz orbitz at drorbitz.ath.cx
Sat Jul 10 04:56:10 CEST 2004


The python language reference says:

" Unlike Standard C, all unrecognized escape sequences are left in the 
string unchanged, i.e., /the backslash is left in the string/. (This 
behavior is useful when debugging: if an escape sequence is mistyped, 
the resulting output is more easily recognized as broken.)"

It seems to me that a syntax error of some kind would be even more 
useful.  For instance if one is dealing with an extremely large output 
they might be able to miss a single missing \t or \n.

Another problem is some beginners seem to be very confused between print 
'\n' and print '\l'

Also, what happens when people perhaps want '\l' and instead of using 
'\\l' type '\l' by accident, and their output looks fine, but later down 
the road it is decided '\l' should be an escape sequence.

Is there a very good reason for this behavior?


More information about the Python-Dev mailing list