I'm new to this and wondering, where's all the code for the modules and packages and stuff that you can import located on my computer.
Can anyone give me a short lesson and help me out?
I'm new to this and wondering, where's all the code for the modules and packages and stuff that you can import located on my computer.
Can anyone give me a short lesson and help me out?
Suppose you want to know the location of xyz
module. You do this on the interpreter
>>> import xyx
>>> xyz.__file__
You'll get the location of the pyc
file from where your module is being imported.
You can also simply do
>>> xyz
to get the module name and the location of the module.
To know about all the possible locations from where the modules are imported, use sys.path
:
>>> import sys
>>> sys.path
This will give you the list of the locations where Python searches for a module when you do import
.
Hope that helps.