[Python-3000] about bytes
Facundo Batista
facundobatista at gmail.com
Fri Jun 27 14:16:37 CEST 2008
2008/6/26 Georg Brandl <g.brandl at gmx.net>:
> Yes. Bytes objects are sequences of bytes, which are integers.
> So, in short, this is the way they work.
I think that the OP confusion comes from the representation.
We have a data type called bytes. They are sequences of bytes. So, I build one:
>>> b = bytes((72, 105))
Then I check:
>>> b[0]
72
>>> b[1]
105
Great! But:
>>> b
b'Hi'
Why I see two letters? Wasn't them bytes? :o
I know that is great to represent bytes between 32 and 127 as letters,
and this has several compatibility details, but I think that the
surprise comes from that place.
If the behaviour were the following....
>>> b
b((72, 105))
...it would be less surprising.
Regards,
--
. Facundo
Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
More information about the Python-3000
mailing list