object identity and equivalence

Sandy Norton sandskyfly at hotmail.com
Mon Nov 19 13:44:16 EST 2001


Erno Kuusela wrote:

>> as a rule, a is b implies a == b (except for odd things like floating
>> point NaNs that compare inequal to themselves).
>> a == b does not imply a is b.

You are correct of course :

>>> x = 10.0
>>> y = 10.0
>>> x is y
0
>>> x == y
1

Two different objects, same value, different identity. Makes sense... must
have been a momentary lapse: I think I better change my coffee... (-:

Almost immediately after I posted my question, I ran another search and
found this link to be helpful:

http://groups.google.com/groups?hl=en&th=7fe7cbcb5f2d40b5&seekm=1002344191.5
78675%40cswreg.cos.agilent.com&frame=off


> There! I've announced my ignorance to the world. Feel better already!
>> congratulations :)

Thanks!

Sandy





More information about the Python-list mailing list