How can you display all modules that are currently loaded in your Python program?

Experience Level: Junior
Tags: Python

Answer

All loaded modules are stored in sys.modules.

To display its names, use the following code:

import sys

print(sys.modules.keys())

Python for beginners
Python for beginners

Are you learning Python ? Try our test we designed to help you progress faster.

Test yourself