How can two Python objects have same id but 'is' operator returns False?
问题 id(t+t), id(t*2) (42838592, 42838592) (t+t) is (t*2) False If two variable point to same object 'is' operator will return true.But first line said both have same id but 'is' operator give false value. 回答1: In the first example, your objects don't overlap in time: one is created then destroyed, then another is created with the same id. When you compare them with is , you are holding onto both objects, so they get different ids. 回答2: As explained by Ned Batchelder's answer, and by the docs for