From 6e6f87bf40447acae09fe053e55eb2b65cf87823 Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Tue, 18 Feb 2014 21:37:51 +0100 Subject: [PATCH] =?UTF-8?q?[attributs]=20Ajout=20d'une=20methode=20=5F=5Fh?= =?UTF-8?q?ash=5F=5F=20=C3=A0=20la=20classe=20Attrs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attributs.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/attributs.py b/attributs.py index c4152a7..cf65fd7 100644 --- a/attributs.py +++ b/attributs.py @@ -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)