Describing Module Loading
-
Python can import four categories of modules:
- Code written in Python (
.pyfiles) - 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.pathfor the following files -
They are listed in search order:
- A directory
foodefining a package foo.pyd(compiled extensions)foo.pyofoo.pycfoo.py
- A directory
References
Previous
Next