[Python-3000] PEP 3137: Immutable Bytes and Mutable Buffer

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Sep 28 04:56:12 CEST 2007


Larry Hastings wrote:
> So now bytes are straddling the difference between strings and the other 
> mapping types:

I think the main reason it seems that way is that we're
using a string-like notation for a bytes literal. With
b[i] returning an int, it really behaves just like any
other sequence.

> So what should the bytes constructor take?  ...  Clearly it should 
 > take an int in the proper range:
 >
>     bytes(97) == b'a'

That should be

   bytes([97])

if it's to be consistent with other sequence constructors:

 >>> list(97)
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
TypeError: iteration over non-sequence

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-3000 mailing list