Describing Module Loading
-
Python can import four categories of modules:
- Code written in Python (
.py
files) - C or C++ extensions
- Packages containing a collection of modules
-
Built-in modules written in C
- These are linked into the Python interpreter
- Code written in Python (
- When looking for a module, the interpreter searches each of the directories in
sys.path
for the following files -
They are listed in search order:
- A directory
foo
defining a package foo.pyd
(compiled extensions)foo.pyo
foo.pyc
foo.py
- A directory
References
Previous
Next