NaN comparisons - Call For Anecdotes

Johann Hibschman jhibschman at
Thu Jul 17 17:12:28 CEST 2014

"Anders J. Munch" <2014 at> writes:
> So far I received exactly the answer I was expecting.  0 examples of
> NaN!=NaN being beneficial.
> I wasn't asking for help, I was making a point.  Whether that will
> lead to improvement of Python, well, I'm not too optimistic, but I
> feel the point was worth making regardless.

Well, I just spotted this thread.  An easy example is, well, pretty much
any case where SQL NULL would be useful.  Say I have lists of borrowers,
the amount owed, and the amount they paid so far.

    nan = float("nan")
    borrowers = ["Alice", "Bob", "Clem", "Dan"]
    amount_owed = [100.0, nan, 200.0, 300.0]
    amount_paid = [100.0, nan, nan, 200.0]
    who_paid_off = [b for (b, ao, ap) in
                          zip(borrowers, amount_owed, amount_paid)
                      if ao == ap]

I want to just get Alice from that list, not Bob.  I don't know how much
Bow owes or how much he's paid, so I certainly don't know that he's paid
off his loan.


More information about the Python-list mailing list