Chris Angelico <ros...@gmail.com>:

> On Wed, Aug 9, 2017 at 7:51 PM, Marko Rauhamaa <ma...@pacujo.net> wrote:
>> Mutable objects can be used as keys into a dictionary.
>
> Only when the objects' mutability does not affect their values.

Up to equality. The objects can carry all kinds of mutable payload as
long as __hash__() and __eq__() don't change with it.

And Python doesn't enforce this in any way except for lists. That's
somewhat unfortunate since sometimes you really would like an immutable
(or rather, no-longer-mutable) list to act as a key.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to