bytearray inconsistencies?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Sat Dec 21 08:13:56 EST 2013
On Sat, 21 Dec 2013 12:29:14 +0000, Mark Lawrence wrote:
> Create a bytearray(range(256)) and partition it on 128. I'd expect to
> see the original effectively cut in half with 128 as the separator. You
> actually get the original with two empty bytearrays, which makes no
> sense to me at all.
I reckon that is a bug. Consider this smaller example:
py> ba = bytearray(range(8))
py> ba
bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07')
py> 3 in ba
True
py> ba.find(3) == ba.index(3) == ba.find(b'\x03')
True
py> ba.partition(b'\x03')
(bytearray(b'\x00\x01\x02'), bytearray(b'\x03'), bytearray(b'\x04\x05\x06
\x07'))
py> ba.partition(3)
(bytearray(b'\x00\x01\x02\x03\x04\x05\x06\x07'), bytearray(b''), bytearray
(b''))
--
Steven
More information about the Python-list
mailing list