To expand on what Ignacio said:
a == b
and a != b
test whether two objects have the same value. You can override an object's __eq__
and __ne__
methods to determine what that means.
a is b
and a is not b
test whether two objects are the same thing. It's like doing id(a) == id(b)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…