is None or == None ?

mk mrkafk at gmail.com
Fri Nov 6 08:20:42 EST 2009


Hello,

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?

Regards,
mk




More information about the Python-list mailing list