Steven D'Aprano wrote:
var is None is a micro-optimization, but that's not why we do it. We do it because usually the correct test is whether var *is* None and not merely equal to None. Any random object might happen to equal None (admittedly most objects don't), but only None is None.
Additionally, some objects that use rich comparisons to return other objects and not booleans will simply fail when compared with None. The situations where you are testing for None are frequently situations where you don't really know the kind of object you might be getting, either.
-- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list