is None or == None ?

Marco Mariani marco at sferacarta.com
Fri Nov 6 09:13:14 EST 2009


Alf P. Steinbach wrote:

> As I understand it, 'is' will always work and will always be efficient 
> (it just checks the variable's type), while '==' can depend on the 
> implementation of equality checking for the other operand's class.

"== None" makes sense, for instance, in the context of the SQLAlchemy 
sql construction layer, where the underlying machinery defines __eq__() 
/ __ne__() and generates the appropriate 'IS NULL' SQL code when 
appropriate.




More information about the Python-list mailing list