[Python-3000] bytes: compare bytes to integer
Guido van Rossum
guido at python.org
Sat Aug 18 21:48:54 CEST 2007
On 8/18/07, Nick Coghlan <ncoghlan at gmail.com> wrote:
> 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()?)
No, I added that as a quick hack during the transition. If someone has
the time, please kill this behavior and fix the (hopefully) few places
that were relying on it.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-3000
mailing list