is None or == None ?

mk mrkafk at
Fri Nov 6 14:20:42 CET 2009


Some claim that one should test for None using:

if x is None:

..but the standard equality which is theoretically safer works as well:

if x == None:

So, which one is recommended?

Can there be two None objects in interpreter's memory? Is testing for 
identity of some variable with None safe? Does language guarantee that? 
Or is it just property of implementation?


More information about the Python-list mailing list