Types for which “is” keyword may be equivalent to equality operator in Python
问题 For some types in Python, the is operator seems to be equivalent to the == operator. For example: >>> 1 is 1 True >>> "a spoon" is "a spoon" True >>> (1 == 1) is (2 == 2) True However, this is not always the case: >>> [] == [] True >>> [] is [] False This makes sense for mutable types such as lists. However, immutable types such as tuples seem to display the same behavior: >>> (1, 2) == (1, 2) True >>> (1, 2) is (1, 2) False This raises several questions: Is the == / is equivalence related to