"Byte" type?

Chris Rebert clp2 at rebertia.com
Sun Feb 15 01:06:42 EST 2009


On Sat, Feb 14, 2009 at 9:56 PM, Lie Ryan <lie.1296 at gmail.com> wrote:
> On Sat, 14 Feb 2009 22:10:41 -0800, John Nagle wrote:
>
>>  >>> xx = b'x'
>
> Isn't this creating a regular byte?
>
> Shouldn't creation of bytearray be:
>
>>>> xx = bytearray(b'x')

Indeed, and slicing that does give back a single byte (which Python
represents as an integer):

>>> b = bytearray(b'abc')
>>> b[0]
97

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com



More information about the Python-list mailing list