Make import algorithm explicit.

Mention extension naming discussion.
This commit is contained in:
Martin v. Löwis 2009-04-29 06:39:41 +00:00
parent 130a57a390
commit 280e65e209
1 changed files with 17 additions and 3 deletions

View File

@ -115,9 +115,20 @@ packages are added to the set sys.namespace_packages.
extend_path will be extended to recognize namespace packages according extend_path will be extended to recognize namespace packages according
to this PEP, and avoid adding directories twice to __path__. to this PEP, and avoid adding directories twice to __path__.
No other change to the importing mechanism is made; searching No other change to the importing mechanism is made; searching modules
modules (including __init__.py) will continue to stop at the first (including __init__.py) will continue to stop at the first module
module encountered. 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 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 users of this feature are encouraged to comment on this particular
question. question.
It also has been proposed to rename the extension from .pkg to
something else.
Copyright Copyright
========= =========