Why (1, 2) is not (1, 2) in python3

Viewed 30

I read article that talk bout tuple http://radar.oreilly.com/2014/10/python-tuples-immutable-but-potentially-changing.html

After reading this article I supposed that a tuple of non mutable object are not mutable and for this reason two tuple of same not mutable object in python is same

>>> a = (1, 2)
>>> b = (1, 2)
>>> a is b
False # but I expect True

But I dont understand why. We have

>>> a = (1,)
>>> b = (1, )    
>>> a is b
True

Please someone can explain me in which case two tuple are same.

0 Answers
Related