in lib/os.py it injects “sys.modules[‘os.path’] = path” so that you’re able to do “import os.path” as though it was a submodule.
sys.modules is a dict in which modules are cached. When you import a module, if it already has been imported somewhere, it gets the instance stored in sys.modules.
包就是一个文件夹下放一个 “_init_.py”
The _init.py files are required to make Python treat the directories as containing packages.
_init_.py can just be an empty file, but it can also execute initialization code for the package or set the _all_ variable
多级package _init_.py从顶至底依次被执行
import用于导入包或模块
A module’s body executes immediately the first time the module is imported in a given run of a program
An import statement creates a new namespace containing all the attributes of the module