python gripes survey

Peter Hansen peter at engcorp.com
Sun Aug 24 12:09:50 EDT 2003


Ryan Lowe wrote:
> 
> "Andrew Dalke" <adalke at mindspring.com> wrote:
> > >>> d = {1: "a"}
> > >>> d.update({True: "b"})
> > >>> d
> > {1: 'b'}
> 
> that is weird; i thought 2.3 made bool its own type? but i guess its still a
> subtype of int. though, i cant imagine when this would come up in a real
> situation anyway.

It could easily come up, and in any case notice that the result is
the same even if the True is replaced with a floating point value 1.0 
in the above example.  Dictionary keys are not matched by identity.

-Peter




More information about the Python-list mailing list