Strange behaviour of 'is'
tofijoy at yahoo.co.in
Thu Sep 21 23:20:46 CEST 2006
I am a bit perplexed by the following behaviour of the 'is' comparator
>>> x = 2.
>>> x is 2.
>>> y = [2., 2.]
>>> y is y
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 and y are the same object!
Does anyone know an explanation for this?
Thank you very much
More information about the Python-list