
- Python 3 Basic Tutorial
- Python 3 - Home
- What is New in Python 3
- Python 3 - Overview
- Python 3 - Environment Setup
- Python 3 - Basic Syntax
- Python 3 - Variable Types
- Python 3 - Basic Operators
- Python 3 - Decision Making
- Python 3 - Loops
- Python 3 - Numbers
- Python 3 - Strings
- Python 3 - Lists
- Python 3 - Tuples
- Python 3 - Dictionary
- Python 3 - Date & Time
- Python 3 - Functions
- Python 3 - Modules
- Python 3 - Files I/O
- Python 3 - Exceptions
How do I find the location of Python module sources?
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. You can manually go and check the PYTHONPATH variable contents to find the directories from where these built in modules are being imported.
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.
- Related Articles
- How do I find the current module name in Python?
- How do I find the location of my Python site-packages directory?
- How do I unload (reload) a Python module?
- How do I disable log messages from the Requests Python module?
- How I can dynamically import Python module?
- How do I calculate the date six months from the current date using the datetime Python module?
- How I can install unidecode python module on Linux?
- How I can check a Python module version at runtime?
- How do I find the largest integer less than x in Python?
- Do I need to set up SAP user for every user of module?
- How can I set the location of minor ticks in Matplotlib?
- How do I find the size of a Java list?
- How do I install Python SciPy?
- How do I get rid of the Python Tkinter root window?
- How do I enumerate functions of a Python class?

Advertisements