what is the keyword "is" for?

sjdevnull at yahoo.com sjdevnull at yahoo.com
Wed Aug 16 04:01:33 EDT 2006


Sybren Stuvel 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
> code and got the expected result:
>
> >>> a = b = 1e1000 / 1e1000
> >>> a is b
> True
> >>> a == b
> True

Probably depends on the implementation.  1e1000/1e1000 yields a NaN
here, and I get True for "a is b" but False for "a==b".  Presumably
comparing a NaN for equality (any comparison?) always yields False.




More information about the Python-list mailing list