Make import algorithm explicit.
Mention extension naming discussion.
This commit is contained in:
parent
130a57a390
commit
280e65e209
20
pep-0382.txt
20
pep-0382.txt
|
@ -115,9 +115,20 @@ packages are added to the set sys.namespace_packages.
|
|||
extend_path will be extended to recognize namespace packages according
|
||||
to this PEP, and avoid adding directories twice to __path__.
|
||||
|
||||
No other change to the importing mechanism is made; searching
|
||||
modules (including __init__.py) will continue to stop at the first
|
||||
module encountered.
|
||||
No other change to the importing mechanism is made; searching modules
|
||||
(including __init__.py) will continue to stop at the first module
|
||||
encountered. In summary, the process import a package foo works like
|
||||
this:
|
||||
|
||||
1. sys.path is search for a directory foo, or a file foo.<ext>.
|
||||
If a file is found, it is treated as a module, and imported.
|
||||
2. if it is a directory, it checks for *.pkg files. If it finds
|
||||
any, a package is created, and its __path__ is extended.
|
||||
3. The __init__ module is imported; this import will search the
|
||||
__path__ that got computed already.
|
||||
4. If neither a *.pkg file nor an __init__.py was found, the
|
||||
directory is skipped, and search for the module/package
|
||||
continues.
|
||||
|
||||
Discussion
|
||||
==========
|
||||
|
@ -149,6 +160,9 @@ having users and tools starting to special-case 2.7). Prospective
|
|||
users of this feature are encouraged to comment on this particular
|
||||
question.
|
||||
|
||||
It also has been proposed to rename the extension from .pkg to
|
||||
something else.
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
|
|
Loading…
Reference in New Issue