美文网首页
Python——"is None"与&quo

Python——"is None"与&quo

作者: 帅气的_xiang | 来源:发表于2017-03-29 22:46 被阅读1776次

is always returns True if it compares the same object instance

Whereas == is ultimately determined by the __eq__() method

i.e.

>>> class Foo(object):
       def __eq__(self, other):
           return True

>>> f = Foo()
>>> f == None
True
>>> f is None
False

相关文章

网友评论

      本文标题:Python——"is None"与&quo

      本文链接:https://www.haomeiwen.com/subject/xznyottx.html