String backslash characters
danb_83 at yahoo.com
Fri Dec 24 06:54:20 CET 2004
> I am new to python, but i am quite curious about the following.
> suppose you had
> print '\378'
> which should not work because \377 is the max. then it displays two
> characters (an 8 and a heart in my case...). What else does'nt quite
> make sense is that if this is an octal why is an 8 accepted?
Because 8 isn't an octal digit, so it's not part of the escape
sequence, but a separate character. It's just like
print 'This string\47s escape sequence does not include the s.'
Your example displays two characters because it is two characters:
'\037' and '8'.
More information about the Python-list