'is not' or '!='

Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Tue Aug 19 05:53:04 EDT 2014


Am 18.08.2014 22:53 schrieb Marko Rauhamaa:

> Frankly, I don't know of any other object that is "==" to the None
> object except None itself, but such objects could possible exist.

class ImitatingNone(object):
     def __eq__(self, other):
         return True # is equal to everything else
         return other is None # is equal only to None
         return not(other) # is equal to everything which is falsey


Pick one.

Thomas



More information about the Python-list mailing list