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}

except that sometimes it can't:

 >>> nan = float("nan")
 >>> {nan, nan}
{nan}

It's fundamentally because NaN is not equal to itself, by design. Dictionaries and sets rely on equality to test for uniqueness of keys or elements.

>>> nan = float("nan")
>>> nan == nan
False

In short, don't do that.

--
Erik Max Francis && m...@alcyone.com && http://www.alcyone.com/max/
 San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis
  There was never a good war or a bad peace.
   -- Benjamin Franklin, 1706-1790
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to