float("nan") in set or as key

MRAB python at mrabarnett.plus.com
Sat May 28 19:41:16 EDT 2011


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}



More information about the Python-list mailing list