summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Holland <william.holland@codethink.co.uk>2015-06-01 13:40:46 +0100
committerWilliam Holland <william.holland@codethink.co.uk>2015-06-01 13:40:46 +0100
commit0c1ffa2b28d907ef71b05eb3777108116955314c (patch)
tree71a5845d5d6d24d785bc3542916e0890fa676160
parent57944355feefdedab20c85de0a784304712187b4 (diff)
downloadkeyboard-python-0c1ffa2b28d907ef71b05eb3777108116955314c.tar.bz2
Remove __str__ method from Key and KeyCombination
As it could result in confusing when debugging
-rw-r--r--keyboardpython/key.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/keyboardpython/key.py b/keyboardpython/key.py
index 0a1414b..47698db 100644
--- a/keyboardpython/key.py
+++ b/keyboardpython/key.py
@@ -17,19 +17,21 @@ def _assert_type(thing,_type):
class KeyCombination:
''' multiple keyboard keys pressed in unison '''
+ def __string(self):
+ keys = self.keys[:]
+ if not self.keys: return ''
+ to_print = keys.pop(0).name
+ while keys: to_print += ' %s' % keys.pop(0).name
+ return to_print
+
+
def __init__(self,*keys):
keys = list(keys)
for i,k in enumerate(keys):
if type(k) is str: keys[i] = Key(k)
else: assert isinstance(k,Key)
self.keys = list(set(keys))
-
- def __str__(self):
- keys = self.keys[:]
- if not self.keys: return ''
- to_print = keys.pop(0).name
- while keys: to_print += ' %s' % keys.pop(0).name
- return to_print
+ self.string = self.__string()
def __eq__(self,other):
if not isinstance(other,KeyCombination):
@@ -98,9 +100,6 @@ class Key:
def __hash__(self):
return hash(str(self))
- def __str__(self):
- return self.name
-
def __nonzero__(self):
return bool(self.name)