On Wed, Aug 9, 2017 at 10:00 PM, Marko Rauhamaa <ma...@pacujo.net> wrote:
> Chris Angelico <ros...@gmail.com>:
>> 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.

I would say the primary key is the "identity" and the rest of the
columns are the "value". But if you're defining "value" solely by the
PK, then you have to ask yourself what you're using this in a
dictionary for - are you going to construct multiple objects
representing the same underlying database row, and expect them to
compare equal? And if they're equal without being identical, how do
you know which one of them actually corresponds to the database? Down
this path lies a form of madness that I want nothing to do with.

>>> 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.

I don't understand your comment. Do you mean that if someone wants to
change it, s/he will? Because that's not really the point. If you're
declaring that a list can now be safely compared by value, you don't
want it to be mutable in any way. That's what a tuple is for.


Reply via email to