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())
Related Python job interview questions
How do you communicate via code what argument types and what return value type a function has?
Python JuniorHow do you define a function in Python?
Python JuniorWhat happens if you import a same module in Python twice and the module contains code print("hello")?
Python JuniorHow do you find out in what folder is the Python imported module stored?
Python JuniorWhen would you use the print() function in Python?
Python Junior