Categories
Python Answers

How to list all functions in a Python module?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *