mirror of
https://github.com/correl/SleekXMPP.git
synced 2024-11-24 03:00:15 +00:00
Hash JIDs based on full JID string.
This makes JID objects equivalent to strings in dictionaries, etc. >>> j = JID('foo@example.com') >>> s = 'foo@example.com' >>> d = {j: 'yay'} >>> d[j] 'yay' >>> d[s] 'yay' >>> d[s] = 'yay!!' >>> d[j] 'yay!!'
This commit is contained in:
parent
2923f56561
commit
86d8736dcc
1 changed files with 4 additions and 0 deletions
|
@ -139,3 +139,7 @@ class JID(object):
|
||||||
def __ne__(self, other):
|
def __ne__(self, other):
|
||||||
"""Two JIDs are considered unequal if they are not equal."""
|
"""Two JIDs are considered unequal if they are not equal."""
|
||||||
return not self == other
|
return not self == other
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
"""Hash a JID based on the string version of its full JID."""
|
||||||
|
return hash(self.full)
|
||||||
|
|
Loading…
Reference in a new issue