- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to retrieve Python module path?
For a pure python module you can find the location of the source files by looking at the module.__file__. For example,
>>> import mymodule >>> mymodule.__file__ C:/Users/Ayush/mymodule.py
Many built-in modules, however,are written in C, and therefore module.__file__ points to a .so file (there is no module.__file__ on Windows), and therefore, you can't see the source.
Running "python -v"from the command line tells you what is being imported and from where. This is useful if you want to know the location of built-in modules.
Advertisements