Bytes indexing returns an int

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Jan 7 06:13:29 EST 2014


Does anyone know what the rationale behind making byte-string indexing
return an int rather than a byte-string of length one?

That is, given b = b'xyz', b[1] returns 121 rather than b'y'.

This is especially surprising when one considers that it's easy to extract
the ordinal value of a byte:

ord(b'y') => 121



-- 
Steven




More information about the Python-list mailing list