real-life identity and "=="
mwh21 at cam.ac.uk
Sun May 14 21:32:43 CEST 2000
weeks at golden.dtc.hp.com ((Greg Weeks)) writes:
> Now, I agree that comparing the *contents* of lists is sometimes useful.
> But "==" should not be the way to do it (just as "=" is not the way to copy
> In practice, it doesn't much matter. But it itches. So close!
> PS: Java has a similar problem. For BitSets for example, the equals() and
> hashCode() methods erroneously assume immutability. Again, so close.
Common Lisp has eq, eql, equal and equalp which are all different ways
of testing equality - and that's probably not enough for a completely
general solution. There is a reason for this; equality is not as
clearly a defined operation as one might think.
BTW, eql is almost exactly what you are asking for in Python.
40. There are two ways to write error-free programs; only the third
-- Alan Perlis, http://www.cs.yale.edu/~perlis-alan/quotes.html
More information about the Python-list