[Python-Dev] Re: redefining is (original) (raw)

Casey Duncan casey at zope.com
Fri Mar 19 16:58:35 EST 2004


On Fri, 19 Mar 2004 16:50:01 -0500 "Andrew Koenig" <ark-mlist at att.net> wrote:

> So identity means the same object, and implies equivalence.

Yes. > Equivalence means they will always have the same value, even > if you do something to one and not the other. This implies > (current value) equality. Yes, unless equality is defined weirdly. For example, IEEE floating-point NaN is supposed to be unequal to itself. > equality just means that they have the same value now. I'm not sure the implication goes the other way. Consider a string-like type for which == ignores case. Then equivalence implies identity, but not the other way. > Since equivalence is a stronger form of equality, why not > just use "===". Seems plausible. > Anything that is === will also be ==, but the extra character > will mark it as special. If the mark isn't strong enough, > perhaps "=~="; in math the ~ often modifies equality to mean > "not identical, but close enough". I wish. But unfortunately sometimes x == x is False.

Right, == is application defined. Whether 'a == b' has no bearing on whether 'a is b' or whether a and b are equivilant. On that grounds I think '===' might be misleading. I'm not convinced that equivilance needs an operator at all, although I know Andrew would prefer that it be as easy to use as 'is'. I think 'equivilant(a, b)' or somesuch would suffice for me.

-Casey



More information about the Python-Dev mailing list