Skip to content

Instantly share code, notes, and snippets.

@ankitr
Created December 26, 2013 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ankitr/8139083 to your computer and use it in GitHub Desktop.
Save ankitr/8139083 to your computer and use it in GitHub Desktop.
This is why I love Python.
def api_method(function, start=None):
"""Returns a dictionary of methods from a list of methods returned."""
method_list = function() #should be an iterable object of functions
method_dict = dict()
for method in method_list:
if start:
def combiner(*args):
start()
method(*args)
method_dict[method.__name__] = combiner
else:
method_dict[method.__name__] = method
return method_dict
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment