[Python-checkins] r72090 - peps/trunk/pep-0382.txt
martin.v.loewis
python-checkins at python.org
Wed Apr 29 08:39:41 CEST 2009
Author: martin.v.loewis
Date: Wed Apr 29 08:39:41 2009
New Revision: 72090
Log:
Make import algorithm explicit.
Mention extension naming discussion.
Modified:
peps/trunk/pep-0382.txt
Modified: peps/trunk/pep-0382.txt
==============================================================================
--- peps/trunk/pep-0382.txt (original)
+++ peps/trunk/pep-0382.txt Wed Apr 29 08:39:41 2009
@@ -115,9 +115,20 @@
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 @@
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
=========
More information about the Python-checkins
mailing list