Are objects with the same id always equal when comparing them with ==?

Not always:

>>> nan = float('nan')
>>> nan is nan
True

or formulated the same way as in the question:

>>> id(nan) == id(nan)
True

but

>>> nan == nan
False

NaN is a strange thing. Per definition it is not equal nor less or greater than itself. But it is the same object. More details why all comparisons have to return False in this SO question.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)