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

> On Wed, Aug 9, 2017 at 8:38 PM, Marko Rauhamaa <ma...@pacujo.net> wrote:
>> 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.
>
> Which means that its value won't change. That's what I said. Two
> things will be equal regardless of that metadata.

In relational-database terms, your "value" is the primary key and your
"metadata" is the rest of the columns.

>> 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.
>
> Then make a tuple out of it. Job done. You're trying to say that its
> value won't now change.

Yeah, when there's a will, there's a way.


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

Reply via email to