Skip to content

Instantly share code, notes, and snippets.

@c7h
Created September 3, 2013 08:38
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 c7h/6421212 to your computer and use it in GitHub Desktop.
Save c7h/6421212 to your computer and use it in GitHub Desktop.
read methods from module, starting with a given string and return a list
def read_funcs_from_module(self, functionname_prefix, module):
"""read methods from module, starting with a given string and return a list"""
moduleValues = module.__dict__.values()
functions_in_module = filter(lambda obj: hasattr(obj, '__call__'), moduleValues)
matching_functions = filter(lambda k: k.__name__.startswith(functionname_prefix), functions_in_module)
return matching_functions
@c7h
Copy link
Author

c7h commented Dec 16, 2015

this might be a helpful piece of black magic to load modules at runtime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment