Created
June 2, 2016 10:11
-
-
Save bmwant/674d5fe2aedc95ccd7edf5a57ab27c8f to your computer and use it in GitHub Desktop.
Inspect usages
This file contains hidden or 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
import operator | |
import inspect | |
def get_module_functions(module, function_prefix=''): | |
""" | |
Get all the functions located inside a module which name started with | |
`function_prefix` | |
""" | |
def filter_function(inspected_function): | |
function_name, function = inspected_function | |
if (function_name.startswith(function_prefix) and | |
inspect.getmodule(function) == module): | |
return True | |
all_functions = map(operator.itemgetter(1), | |
filter(filter_function, | |
inspect.getmembers(module, inspect.isfunction))) | |
return all_functions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment