Function Analysis of the _ init _. py file in the Python module package,
This example describes the _ init _. py file function in the Python module package. We will share this with you for your reference. The details are as follows:
It has been more than a year since django was used for development __. the significance of the existence of the py file. It is too important to see the Introduction to it.
Module package:
A package is usually a directory. The first file under the directory is _ init _. py. Then there are some module files and subdirectories. If there are also _ init _. py in the subdirectory, It is the sub-package of this package.
Like this:
Package1/_ init _. py Module1.py Module2.py Package2
Package1/Package2/_ init _. py Module1.py Module2.py
We can import a package as follows:
Import Package1
You can also call a sub-module and sub-package:
From Package1 import Module1 from Package1 import Package2, import Packag1.Module1, import Packag1.Package2
You can go deep into several layers of Package Structure:
From Package1.Package2 import Module1, import Package1.Package2. Module1
In general, I think the essence of the package should be in the _ init _. py file.