[attributs] Ajout d'une methode __hash__ à la classe Attrs

This commit is contained in:
Valentin Samir 2014-02-18 21:37:51 +01:00
parent 45947b1871
commit 6e6f87bf40

View file

@ -271,6 +271,12 @@ class Attr(object):
self.parent = Parent
self.parse_value(val)
def __hash__(self):
if hasattr(self.value, "__hash__") and self.value.__hash__ is not None:
return self.value.__hash__()
else:
return str(self).__hash__()
def __eq__(self, item):
if isinstance(item, self.__class__):
return str(self) == str(item)