>>> class C(object): ... def __init__(self, val): ... self.val = val ... def __cmp__(self, other): ... return cmp(self.val, other.val) ... >>> a = C("SPAM") >>> b = C("EGGS") >>> d = C("SPAM") >>> c = a >>> a is b False >>> a == b False >>> a == d True >>> a is d False >>> a is c True >>> a == c True