] > Testing for NaN without depending on Numpy (Logilab.org)

How can I test if a python float is "not a number" without depending on numpy? Simple, a nan value is different to any other value, including itself:

def isnan(x):
    return isinstance(x, float) and x!=x

blog entry of

Logilab.org - en