Re: (objects as) mutable dictionary keys

From: Antoon Pardon (apardon_at_forel.vub.ac.be)
Date: 01/14/05


Date: 14 Jan 2005 15:41:44 GMT

Op 2005-01-14, Peter Maas schreef <peter@somewhere.com>:
> I have summarized the discussion about the usability of lists (and
> and other mutable types) as dictionary keys and put it into the
> Python wiki.URL: http://www.python.org/moin/DictionaryKeys.
>
> This summary might be used as a reference should the 'mutable
> dictionary keys' issue come up again in c.l.py.
>
I had a look and I think you should correct the followingr:

  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. It may be discouraged but it is not
impossible since I have already done so.

-- 
Antoon Pardon


Relevant Pages

  • Re: (objects as) mutable dictionary keys
    ... >>I have summarized the discussion about the usability of lists (and ... >>and other mutable types) as dictionary keys and put it into the ... >>dictionary keys' issue come up again in c.l.py. ... therefore not recommended in Python. ...
    (comp.lang.python)
  • Re: (objects as) mutable dictionary keys
    ... > I have summarized the discussion about the usability of lists (and ... > and other mutable types) as dictionary keys and put it into the ... Note that Peter Maas has put this up on the Python wiki, ...
    (comp.lang.python)
  • Re: (objects as) mutable dictionary keys
    ... > and other mutable types) as dictionary keys and put it into the ... > dictionary keys' issue come up again in c.l.py. ... Lists are not safe ... _because_ the cmp function is NOT a compare of id, ...
    (comp.lang.python)
  • Re: (objects as) mutable dictionary keys
    ... I have summarized the discussion about the usability of lists (and ... and other mutable types) as dictionary keys and put it into the ... Python wiki.URL: http://www.python.org/moin/DictionaryKeys. ... dictionary keys' issue come up again in c.l.py. ...
    (comp.lang.python)
  • Re: objects as mutable dictionary keys
    ... for lists, and it isn't defined by default for user ... >> dictionaries recently, and the mainstream opinion was that dictionary ... >> keys must not be mutable, so lists are not allowed as dictionary keys. ... > - Dictionary lookup with list literals would be impossible. ...
    (comp.lang.python)