Classes that override __eq__ also need to define __hash__.

This commit is contained in:
Raymond Hettinger 2010-04-05 18:53:43 +00:00
parent 5e0c2748fb
commit e1d665a90e
2 changed files with 9 additions and 0 deletions

View file

@ -93,4 +93,6 @@ def cmp_to_key(mycmp):
return mycmp(self.obj, other.obj) >= 0
def __ne__(self, other):
return mycmp(self.obj, other.obj) != 0
def __hash__(self):
raise TypeError('hash not implemented')
return K