Skip to content

Instantly share code, notes, and snippets.

@Sean-Bradley
Created April 10, 2019 20:15
Show Gist options
  • Save Sean-Bradley/c4a07f530d050106959c0e9f74ecd56f to your computer and use it in GitHub Desktop.
Save Sean-Bradley/c4a07f530d050106959c0e9f74ecd56f to your computer and use it in GitHub Desktop.
class Switch:
"""The Invoker Class"""
def __init__(self):
self._commands = {}
self._history = []
@property
def history(self):
return self._history
def register(self, command_name, command):
self._commands[command_name] = command
def execute(self, command_name):
if command_name in self._commands.keys():
self._history.append((time.time(), command_name))
self._commands[command_name].execute()
else:
print(f"Command [{command_name}] not recognised")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment