String backslash characters

Binu K S binux.lists at gmail.com
Fri Dec 24 06:00:30 CET 2004


'\378' becomes a two character string. The first character is '\37'
and the second character is '8'.

>>> str = '\378'
>>> str[0]
'\x1f'
>>> str[1]
'8'
>>> 

On 23 Dec 2004 20:53:13 -0800, PD <albaalu at gmail.com> wrote:
> Hello,
> 
> 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?
> 
> for instance is 378 really 11, 111, 1000 which is then the two
> characters: <00000001>,<1111000>. And why is this accepted?
> 
> I apologize if this has been discussed or if it is obvious. I would
> appreciate it if someone could clear me up.
> 
> Yours,
> PD
> 
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list