For tall buildings to avoid worry, worry also follow me on tall buildings. The line of several country changed, how many friends do bald.
To go off, to go off. Adults do not always Monkey? Source clouds no fixed yuan, it was like the clouds are free.
I learned Python from short work of them one thing, the more modular, the more you will find seemingly ordinary import python is a great mystery.
- Search path when the python python file references are often pwd terminal of the current. (Sys or may be at the os module append expected path)
- In python looks a bit like a reference file is executed the file again.
- Relative path python is really a lot of restrictions, in my opinion seems to be the set of her when I could use?
So, ah, I do not make people do not understand Python reference mechanism of it! JOJO!
From the Python Software Foundation learned of the reference system (ImportSystem):
When a import
time command is executed, the program performs a standard library __import__()
functions. It is worth noting that if you are using importlib.import_module()
can bypass this function uses its own reference mechanism.
When a module is first introduced, Python looks for the module, if found, will create a module object (module object). otherwiseraise ModuleNotFoundError
Package
Package concept in Python is structured to manage numerous modules. It is generally understood Package is a folder, rather Module is a separate file. But in fact only Module Package subclass, the only difference is a variable having a Module Package does not have__path__
When introduced from the sub-packages Package (subpackage) of the main package (parent package) is __init__.py
also executed (you want to get a little matryoshka nesting dolls have large open concept of)
This is an example
parent/
__init__.py
one/
__init__.py
two/
__init__.py
three/
__init__.py
If we execute import parent.one
when we will first execute parent.__init__.py
and then execute one.__init__.py
.
Namespace package
(Ah, see this namespace to a head two large)
Namespace is a python objects in the index system. Namespace package is mainly to solve the current program does not object module file system (a compressed package, there is a network location and other forms) situation. Currently not encountered this kind of application environment, it would not be understood in detail.
Find module
This is more important ┗ | `O '| ┛ wailing ~~
This package has been introduced Yo
All packets have been introduced in the sys.modules
reservoir so as to avoid repeating the introduction.
Look So far, my doubts have not answered. . . But it has been very sleepy, and by chance the series again?