Marko Rauhamaa marko at
Mon Mar 3 23:22:55 CET 2014

Jerry Hill <malaclypse2 at>:

> except for the fact that there has been 20 years of custom saying that
> comparing to None with equality is wrong.

"if foo == None" is not wrong in any manner. It's just that if you are
comfortable with the "is" operator and its semantics, "if foo is None"
is slightly more natural.

You generally use "==" if more than one object could be equal. If you
know there's only one object of the kind, you convey that knowledge by
the use of "is" even when functionally, it doesn't matter.


More information about the Python-list mailing list