summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Holland <william.holland@codethink.co.uk>2015-06-04 21:19:43 +0100
committerWilliam Holland <william.holland@codethink.co.uk>2015-06-04 21:21:11 +0100
commit7736e787807beeed3500ab411da11cedb0452b23 (patch)
tree33ca91920cf4788453c7f447b7d1a7b671350995
parent7bede663c43c27b329a0cd0588dc08441b64c03f (diff)
downloadkeyboard-python-7736e787807beeed3500ab411da11cedb0452b23.tar.bz2
Fix equality not working for Key and KeyCombination
-rw-r--r--keyboardpython/key.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/keyboardpython/key.py b/keyboardpython/key.py
index 7ecca69..92ece3c 100644
--- a/keyboardpython/key.py
+++ b/keyboardpython/key.py
@@ -36,13 +36,13 @@ class KeyCombination:
def __eq__(self,other):
if not isinstance(other,KeyCombination):
if not isinstance(other,Key): return False
- return str(self) == str(other)
+ return self.string == other.string
def __ne__(self,other):
return not self.__eq__(self,other)
def __hash__(self):
- return hash(str(self))
+ return hash(self.string)
def __nonzero__(self):
return bool(self.string)
@@ -91,11 +91,12 @@ class Key:
def __init__(self,name):
_assert_type(name,str)
self.name = name
+ self.string = self.name
def __eq__(self,other):
if not isinstance(other,KeyCombination):
if not isinstance(other,Key): return False
- return str(self) == str(other)
+ return self.string == other.string
def __ne__(self,other):
return not self.__eq__(self,other)