class Foo: def __init__(self, num): self.num = num def __eq__(self, other): return self.num == other.num def __ne__(self, other): # __ne__ represents the != operator return self.num != other.num