Skip to content

Instantly share code, notes, and snippets.

@c7h c7h/gist:6421212
Created Sep 3, 2013

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.