[attributs] Ajout d'une methode __hash__ à la classe Attrs
This commit is contained in:
parent
45947b1871
commit
6e6f87bf40
1 changed files with 6 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue