[Python-3000] bytes: compare bytes to integer
Nick Coghlan
ncoghlan at gmail.com
Sat Aug 18 15:04:38 CEST 2007
Victor Stinner wrote:
> Hi,
>
> I don't like the behaviour of Python 3000 when we compare a bytes strings
> with length=1:
> >>> b'xyz'[0] == b'x'
> False
>
> The code can be see as:
> >>> ord(b'x') == b'x'
> False
This seems to suggest its own solution:
bytes_obj[0] == ord('x')
(Given that ord converts *characters* to bytes, does it actually make
sense to allow a bytes object as an argument to ord()?)
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list