"
This article is part of in the series

Python provides a really easy and simple way of retrieving file paths of an imported module. This can be really helpful if you're trying to find a file path quickly and you're working on a project that has multiple subdirectories, or if you're using scripts or programs that are primarily accessed through the command line. If you're in a similar situation, you can use the following method to find the exact file path of your module:

import os
print(os)

That's it. Use this trick whenever you want to know the exact location of module files in your code. The accurate file path of the module should then be printed for you. It will probably look something like this:

<module 'os' from '/usr/lib/python2.7/os.pyc'>