Skip to content

Instantly share code, notes, and snippets.

@jriddy
Created December 15, 2015 16:40
Show Gist options
  • Save jriddy/61f4174c3206020ee480 to your computer and use it in GitHub Desktop.
Save jriddy/61f4174c3206020ee480 to your computer and use it in GitHub Desktop.
# Test on delivery
def register(key):
def decorator(method):
method.response = key
return method
return decorator
@register('$')
def msgtype_DOLLARSIGN(self, blah):
pass
class Whatever(object):
def __init__(self):
self.registry = {}
for x in (getattr(self, k) for k in dir(self)):
if callable(x) and hasattr(self, 'response'):
self.registry.update({getattr(self, 'response'): x})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment