On 9/26/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: > [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. >
looks like my response in the other thread suggesting allowing comparisons of len==1 to ints was already mentioned before me. yay. I'm +0.5 on the idea of allowing the len==1 to int comparison and returning ints for the bytes/buffer indices and iteration. glad to see this as a PEP, it feels more real. :) -gps _______________________________________________ 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