Documentation for object.__hash__(self)
The only required property is that objects which compare equal have the same hash value; it is advised to somehow mix together (e.g. using exclusive or) the hash values for the components of the object that also play a part in comparison of objects.
def __hash__(self):
return hash(self.a) ^ hash(self.b)