On Sun, 2011-05-29 at 00:41 +0100, MRAB wrote: > Here's a curiosity. float("nan") can occur multiple times in a set or as > a key in a dict: > > >>> {float("nan"), float("nan")} > {nan, nan} > These two nans are not equal (they are two different nans)
> except that sometimes it can't: > > >>> nan = float("nan") > >>> {nan, nan} > {nan} This is the same nan, so it is equal to itself. Two "nan"s are not equal in the manner that 1.0 and 1.0 are equal: >>> 1.0 == 1.0 True >>> float("nan") == float("nan") False I can't cite this in a spec, but it makes sense (to me) that two things which are nan are not necessarily the same nan. -- http://mail.python.org/mailman/listinfo/python-list