<var> is None vs. <var> == None
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Fri Jan 23 20:16:51 EST 2009
On Fri, 23 Jan 2009 16:28:15 -0800, Gary Herron wrote:
> If something
> *equals* None, it also *is* None. This is a consequence of the fact
> that there is only ever one value of None anywhere in the system.
...
> The only way something can *equal* None is if it *is* None.
>>> class Empty:
... def __eq__(self, other):
... return not bool(other)
...
>>> e = Empty()
>>> e == None
True
>>> e is None
False
--
Steven
More information about the Python-list
mailing list