Wiadomość napisana przez Hrvoje Niksic w dniu 2011-04-27, o godz. 11:37: > The other day I was surprised to learn this: > > >>> nan = float('nan') > >>> nan == nan > False > >>> [nan] == [nan] > True # also True in tuples, dicts, etc. > > # also: > >>> l = [nan] > >>> nan in l > True > >>> l.index(nan) > 0 > >>> l[0] == nan > False > This surprises me as well. I guess this is all related to the fact that: >>> nan is nan True Have a look at this as well: >>> inf = float('inf') >>> inf == inf True >>> [inf] == [inf] True >>> l = [inf] >>> inf in l True >>> l.index(inf) 0 >>> l[0] == inf True # Or even: >>> inf+1 == inf-1 True For the infinity part, I believe this is related to the funky IEEE 754 standard. I found some discussion about this here: http://compilers.iecc.com/comparch/article/98-07-134 -- Best regards, Łukasz Langa
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4