On 2006-09-21, Fijoy George <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am a bit perplexed by the following behaviour of the 'is' comparator
>
>>>> x = 2.
>>>> x is 2.
> False
>>>> y = [2., 2.]
>>>> y[0] is y[1]
> True
>
> My understanding was that every literal is a constructure of an object. 
> Thus, the '2.' in 'x = 2.' and the '2.' in 'x is 2.' are different objects. 
> Therefore, the comparison yields false.
>
> 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
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to