NaN comparisons - Call For Anecdotes

Skip Montanaro skip at pobox.com
Tue Jul 8 17:24:50 CEST 2014


On Tue, Jul 8, 2014 at 10:19 AM, Chris Angelico <rosuav at gmail.com> wrote:
> For hash keys, float object identity will successfully look them up:
>>>> d={}
>>>> d[float("nan")]=1
>>>> d[float("nan")]=2
>>>> x=float("nan")
>>>> d[x]=3
>>>> d[x]
> 3
>>>> d
> {nan: 1, nan: 2, nan: 3}

Neat!

S



More information about the Python-list mailing list