[Python-checkins] r52570 - sandbox/trunk/import_in_py/importer.py
brett.cannon
python-checkins at python.org
Wed Nov 1 02:04:39 CET 2006
Author: brett.cannon
Date: Wed Nov 1 02:04:38 2006
New Revision: 52570
Modified:
sandbox/trunk/import_in_py/importer.py
Log:
Add basic outline of how to tackle packages. Also tweak some comments.
Modified: sandbox/trunk/import_in_py/importer.py
==============================================================================
--- sandbox/trunk/import_in_py/importer.py (original)
+++ sandbox/trunk/import_in_py/importer.py Wed Nov 1 02:04:38 2006
@@ -25,6 +25,8 @@
Package notes
=============
+Semantics
+---------
* __path__ is set to the deepest package directory, not the top package
directory [introspection].
* __path__ is not inherited in any way [introspection].
@@ -60,6 +62,18 @@
this means that the usual path_hooks/path_importer_cache dance is done for
entries in __path__ instead of sys.path (meta_path is still searched
regardless of the value of __path__) [PEP 302].
+
+Implementing
+------------
+1. Imports of top-level package.
+ + __path__ set.
+2. Importing within package.
+ + Root package already imported.
+ + Root package not imported yet.
+3. fromlist semantics.
+4. Relative imports.
+ + Py3K semantics.
+ + 2.x semantics.
Things to be exposed at the Python level
@@ -618,17 +632,14 @@
the module represented by the full dotted name is returned.
"""
- # XXX Ignores fromlist.
# XXX Does not handle packages yet, which means no absolute/relative imports
# or fromlist worries.
- # Check for a relative import; if it is one make it absolute to try to import that,
+ # XXX Check for a relative import; if it is one make it absolute to try to import that,
# otherwise import as a top-level module.
- # XXX
- # Import submodules; short-circuits search if module is already
+ # XXX Import submodules; short-circuits search if module is already
# in sys.modules.
- # XXX
module = self.import_(name)
# When fromlist is not specified, return the root module (i.e., module
# up to first dot).
More information about the Python-checkins
mailing list