"Byte" type?

Erik Max Francis max at alcyone.com
Sun Feb 15 00:58:54 EST 2009


John Nagle wrote:
>     With "bytearray", the element type is considered to be "unsigned byte",
> or so says PEP 3137: "The element data type is always 'B' (i.e. unsigned 
> byte)."
> 
> Let's try:
> 
> Python 2.6.1 (r261:67517, Dec  4 2008, 16:51:00) [MSC v.1500 32 bit 
> (Intel)] on
> win32
>  >>> xx = b'x'
>  >>> repr(xx)
> "'x'"
>  >>> repr(xx[0])
> "'x'"
>  >>> repr(xx[0][0])
> "'x'"
>  >>>
> 
> But that's not what "repr" indicates.  The bytearray element is apparently
> being promoted to "bytes" as soon as it comes out of the array.

There's no distinction byte type.  A single character of a bytes type is 
also a bytes.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   Did you ever love somebody / Did you ever really care
    -- Cassandra Wilson



More information about the Python-list mailing list