Created
September 3, 2013 08:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this might be a helpful piece of black magic to load modules at runtime.