[Python-3000] bytes and dicts (was: PEP 3137: Immutable Bytes and Mutable Buffer)

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Sep 29 01:57:10 CEST 2007


Adam Hupp wrote:
> Would it make sense to have dict ignore TypeError on lookups?
> Alternatively, the byte/str comparison could throw a specific subclass
> of TypeError that dict ignored e.g. IncompatibleComparisonError.

Presumably the reason for making strings and bytes uncomparable
in the first place is to catch errors due to unwittingly mixing
strings and bytes. Having dicts ignore the exception would
partly defeat that.

I'm not all that comfortable with the idea of having things
that can't even be compared for equality. Is this meant to be
a permanent feature of the language, or just something to help
people get over the transition? Could it be dropped once
everyone has got over the shock of having strings and bytes
being different things?

--
Greg


More information about the Python-3000 mailing list