Modules

  1. What are modules exactly?
  2. How does Python load modules?
    1. How to import without the import statement
    2. Imports and importlib

什麼是 Module?

module

An object that serves as an organizational unit of Python code. Modules have a namespace containing arbitrary Python objects. Modules are loaded into Python by the process of importing.

Glossary

importing

The process by which Python code in one module is made available to Python code in another module.

Glossary

Here is a flow chart describing how modules are loaded:

image.png

PEP 3147 – PYC Repository Directories | peps.python.org