Python Basic Doubt

Terry Reedy tjreedy at udel.edu
Sat Aug 10 21:25:36 EDT 2013


On 8/10/2013 8:42 PM, Gary Herron wrote:

> But for each of your examples, using "==" is equivalent to using "is".
> Each of
>      if something == None
>      if device == _not passed
>      if device != None
> would all work as expected.  In none of those cases is "is" actually
> needed.

class EqualAll:
     def __eq__(self, other): return True

ea = EqualAll()
print(ea == None)
print(ea == float('nan'))
 >>>
True
True

-- 
Terry Jan Reedy




More information about the Python-list mailing list