what is the keyword "is" for?

Alex Martelli aleax at mac.com
Wed Aug 16 11:15:57 EDT 2006


Sybren Stuvel <sybrenUSE at YOURthirdtower.com.imagination> wrote:

> Dan Bishop enlightened us with:
> >>>> a = b = 1e1000 / 1e1000
> >>>> a is b
> > True
> >>>> a == b
> > False
> 
> If "a is b" then they refer to the same object, hence a == b. It
> cannot be otherwise, unless Python starts to defy logic. I copied your

Python also needs to respect standards (such as IEEE 754 for
floating-point arithmetic, and the SQL standards) which do specify the
existence of special objects that "are not equal to anything" including
themselves -- Nan and NULL respectively for these two standards.

We're talking about extremely widespread international standards
developed by huge body of professionals which do include professional
logicians, so I doubt they "defy logic".  Python tries to delegate FP to
the underlying hardware and SQL to an external relational DB engine, so
it should be as compliant as the pieces of infrastructure it's using --
which seems to me to be a good architectural decision (not just for
speed and ease of coding, but to ensure any anomaly is somebody else's
fault:-).


Alex



More information about the Python-list mailing list