Skip to content

Instantly share code, notes, and snippets.

@radix
Created August 17, 2015 21:19
Show Gist options
  • Save radix/e25fbf4fdf224dbcebed to your computer and use it in GitHub Desktop.
Save radix/e25fbf4fdf224dbcebed to your computer and use it in GitHub Desktop.
class MethodNameDispatcherThing(object):
def __init__(self, target, types_to_method_names):
self.target = target
self.types_to_method_names = types_to_method_names
def __call__(self, intent):
method_name = self.types_to_method_names.get(type(intent), None)
if method_name is not None:
return getattr(self.target, method_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment