what is the keyword "is" for?

Simon Forman rogue_pedro at yahoo.com
Wed Aug 16 04:03:16 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
>
> Sybren

Python 2.4.3 (#2, Apr 27 2006, 14:43:58)
[GCC 4.0.3 (Ubuntu 4.0.3-1ubuntu5)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

|>> a = b = 1e1000 / 1e1000
|>> a is b
True
|>> a == b
False

Huh.  Weird.  I copied it too and got the "wrong" result.




More information about the Python-list mailing list