[Python-ideas] checking for identity before comparing built-in objects
Steven D'Aprano
steve at pearwood.info
Tue Oct 9 06:26:35 CEST 2012
On Mon, Oct 08, 2012 at 09:29:42AM -0700, Guido van Rossum wrote:
> It's not about equality. If you ask whether two NaNs are *unequal* the
> answer is *also* False.
Not so. I think you are conflating NAN equality/inequality with ordering
comparisons. Using Python 3.3:
py> nan = float('nan')
py> nan > 0
False
py> nan < 0
False
py> nan == 0
False
py> nan != 0
True
but:
py> nan == nan
False
py> nan != nan
True
--
Steven
More information about the Python-ideas
mailing list