The cleanest way to do these things is to use the inspect module. It has a getmembers
function that takes a predicate as the second argument. You can use isfunction
as the predicate.
import inspect
all_functions = inspect.getmembers(module, inspect.isfunction)
Now, all_functions
will be a list of tuples where the first element is the name of the function and the second element is the function itself.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…