[Python-Dev] redefining is
Walter Dörwald
walter.doerwald at livinglogic.de
Fri Mar 19 13:52:54 EST 2004
Michael Chermside wrote:
> Andrew Koenig writes:
>
>>The reason for that, I think, is that there are really three kinds of
>>"equality" that make sense, and only two of them are reasonably available:
>>
>> Value equality (==, which might be user-defined, because
>> the concept of "value" can be user-defined);
And there might be more than one user.
>> Object identity ("is")
>>
>> Object equivalence (no easy way of expressing it today)
>>
>>By "object equivalence", I mean mutual substitutability--which is the same
>>as identity for mutable objects, but not for immutable ones.
But this mutual substitutability is context dependant.
"is" guarantees that both objects are mutual substitutable in
*any* context. "==" defines the mutual substitutability for the
"default" context. Any other context is application dependant,
so the comparison function should be defined by the application.
Bye,
Walter Dörwald
More information about the Python-Dev
mailing list