Re: (objects as) mutable dictionary keys

From: Just (just_at_xs4all.nl)
Date: 01/17/05


Date: Mon, 17 Jan 2005 13:52:47 +0100

In article <csgb3d$hjn$1@swifty.westend.com>,
 Peter Maas <peter@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



Relevant Pages

  • Re: Python is faster than C
    ... > (there is no reason why all lists should be arrays of PyObjects ... > Python type str, so that the difference doesn't show up and the Python ... thus freeing the programmer from even specifying the operations. ... and keeping in mind that some of these optimizations ...
    (comp.lang.python)
  • Python-URL! - weekly Python news and links (Jun 19)
    ... "Regarding a Java programmer moving to Python, ... change is about the abundant use of built in data types of Python. ... this using lists, dicts and tuples?' ...
    (comp.lang.python)
  • Python-URL! - weekly Python news and links (Jun 19)
    ... "Regarding a Java programmer moving to Python, ... change is about the abundant use of built in data types of Python. ... this using lists, dicts and tuples?' ...
    (comp.lang.python.announce)
  • Re: (objects as) mutable dictionary keys
    ... > Dictionary lookup with mutable types like lists is a source of ... > unpleasant surprises for the programmer and therefore impossible in ... > It is not impossible in Python. ...
    (comp.lang.python)
  • python-dev Summary for 2003-10-16 through 2003-11-15
    ... This is the twenty-eighth and twenty-ninth summaries written by Brett ... The in-development version of the documentation for Python can be found ... If you have ever wanted to see linked lists used in Python in a rather ... Contributing threads: ...
    (comp.lang.python)