Strange behaviour of 'is'

Klaas mike.klaas at gmail.com
Thu Sep 21 18:17:01 EDT 2006


Ben C wrote:
> On 2006-09-21, Fijoy George <tofijoy at yahoo.co.in> wrote:

> > But my understanding does not explain the result of the second comparison.
> > According to the experiment, y[0] and y[1] are the same object!
>
> I'm as baffled as you, even more so its implication:

> >>> a = 2.
> >>> b = 2.
>
> >>> a is b
> False
>
> >>> a, b = 2., 2.
> >>> a is b
> True

It is suprising that it is easier to recognize identical constants
within the same expression?

-Mike




More information about the Python-list mailing list