float("nan") in set or as key

rusi rustompmody at gmail.com
Sat Jun 4 03:52:17 EDT 2011


On Jun 4, 4:29 am, Nobody <nob... at nowhere.com> wrote:
> On Fri, 03 Jun 2011 14:52:39 +0000, Grant Edwards wrote:
> >> It's arguable that NaN itself simply shouldn't exist in Python; if
> >> the FPU ever generates a NaN, Python should raise an exception at
> >> that point.
>

>
> If you're "fluent" in IEEE-754, then you won't find its behaviour
> unexpected. OTOH, if you are approach the issue without preconceptions,
> you're likely to notice that you effectively have one exception mechanism
> for floating-point and another for everything else.

Three actually: None, nan and exceptions
Furthermore in boolean contexts nan behaves like True whereas None
behaves like false.



More information about the Python-list mailing list