In python, to check whether an object equal or not equal to another object is equal or not, special functions are called. __eq__ is called for verification == , and __ne__ is called for verification !=
In general, an object can define __ne__ differently than __eq__ .
eg.
class Junk(object): def __ne__(self, other): return False def __eq__(self, other): return False j = Junk() print not j == 1 print j != 1
This gives:
True False
However, this would be especially vicious. Usually you will never have to worry about this.
source share