Sometimes, we want to retrieve a module’s path with Python.
In this article, we’ll look at how to retrieve a module’s path with Python.
How to retrieve a module’s path with Python?
To retrieve a module’s path with Python, we can call os.path.abspath
.
For instance, we write
import os
path = os.path.abspath(a_module.__file__)
to call os.path.abspath
with a_module.__file__
to get the absolute path of the a_module
module.
Conclusion
To retrieve a module’s path with Python, we can call os.path.abspath
.