(objects as) mutable dictionary keys

Just just at xs4all.nl
Mon Jan 17 07:52:47 EST 2005


In article <csgb3d$hjn$1 at swifty.westend.com>,
 Peter Maas <peter at somewhere.com> wrote:

> Antoon Pardon schrieb:
> >   Dictionary lookup with mutable types like lists is a source of
> >   unpleasant surprises for the programmer and therefore impossible in
> >   Python.
> > 
> > 
> > It is not impossible in Python.

Is too.

> > It may be discouraged but it is not
> > impossible since I have already done so.
> 
> Wouldn't this raise a TypeError? Or did you wrap them with an object?

He created a list subclass that redefines __hash__, so he cheated :).

Just



More information about the Python-list mailing list