Sometimes, we want to list all functions in a Python module.
In this article, we’ll look at how to list all functions in a Python module.
How to list all functions in a Python module?
To list all functions in a Python module, we can use the inspect
module.
For instance, we write
from inspect import getmembers, isfunction
from somemodule import foo
print(getmembers(foo, isfunction))
to call getmembers
with the foo
module and the isfunction
function to return a list of all functions in the foo
module.
Conclusion
To list all functions in a Python module, we can use the inspect
module.