Is there any difference between "foo is None" and "foo == None"?
Posted
by Joe Shaw
on Stack Overflow
See other posts from Stack Overflow
or by Joe Shaw
Published on 2008-08-25T18:27:16Z
Indexed on
2010/05/28
21:12 UTC
Read the original article
Hit count: 188
python
Is there any difference between:
if foo is None: pass
and
if foo == None: pass
The convention that I've seen in most Python code (and the code I myself write) is the former, but I recently came across code which uses the latter. None is an instance (and the only instance, IIRC) of NoneType, so it shouldn't matter, right? Are there any circumstances in which it might?
© Stack Overflow or respective owner