[PEP 3137] > > **Open Issue:** I'm undecided on whether indexing bytes and buffer > > objects should return small ints (like the bytes type in 3.0a1, and > > like lists or array.array('B')), or bytes/buffer objects of length 1 > > (like the str type). The latter (str-like) approach will ease porting > > code from Python 2.x; but it makes it harder to extract values from a > > bytes array.
On 9/26/07, Brett Cannon <[EMAIL PROTECTED]> wrote: > How much do you care about making the 2 -> 3 transition easy? If you > don't go the str way then comparisons like ``bytes_[0] == b"A"`` won't > work unless you allow comparisons between ints and length 1 > bytes/buffers. Extracting a single item is not horrendous if you pass > it to int(). > > Personally I say go with the list-like semantics. Having the > following code return false seems odd (but not ridiculous) to me:: > > stuff = bytes([0, 1]) > stuff[1] = 42 > stuff[1] == 42 > > So unless int comparisons are allowed I am -0 on the str-like semantics. int comparisons would stick out like a sore thumb, especially since they can only be reasonably made to work on 1-byte strings. I'm still undecided (despite Marcin's eloquent argument for ints as bytes) but I'm open for votes for this case. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com