Understanding Python's “is” operator

前端 未结 11 2277
别那么骄傲
别那么骄傲 2020-11-21 22:42

The is operator does not match the values of the variables, but the instances themselves.

What does it really mean?

11条回答
  •  礼貌的吻别
    2020-11-21 22:59

    It compares object identity, that is, whether the variables refer to the same object in memory. It's like the == in Java or C (when comparing pointers).

提交回复
热议问题