[Python-checkins] r55750 - sandbox/trunk/import_in_py/pseudocode.py
brett.cannon
python-checkins at python.org
Sun Jun 3 21:52:50 CEST 2007
Author: brett.cannon
Date: Sun Jun 3 21:52:47 2007
New Revision: 55750
Modified:
sandbox/trunk/import_in_py/pseudocode.py
Log:
Put pseudocode into a function format so that one knows where arguments come
from.
Modified: sandbox/trunk/import_in_py/pseudocode.py
==============================================================================
--- sandbox/trunk/import_in_py/pseudocode.py (original)
+++ sandbox/trunk/import_in_py/pseudocode.py Sun Jun 3 21:52:47 2007
@@ -1,21 +1,24 @@
-"""Pseudocode to explain how importing works.
+raise ImportError("module is just pseudocode")
-Caveats:
- + Classic relative import semantics are not currently covered.
- + Assume all code runs with the import lock held.
+def __import__(name, globals, locals, fromlist, level):
+ """Pseudocode to explain how importing works.
-"""
-if level != 0: # Relative import.
- name = resolve_name(name, level) # XXX
-# Import each parent in the name, starting at root.
-# Skipping over details of constructing each parent name and setting the proper
-# attribute on the parent for newly imported modules.
-for parent in name:
- if parent in sys.modules:
- continue
- for meta_importer in sys.meta_path:
- check_meta_path(parent, meta_importer) # XXX
- for path_entry in sys.path:
- check_path(parent, path_entry) # XXX
- # XXX error: not found
-return module_to_return(path, fromlist) # XXX
+ Caveats:
+ + Classic relative import semantics are not currently covered.
+ + Assume all code runs with the import lock held.
+
+ """
+ if level != 0: # Relative import.
+ name = resolve_name(name, level) # XXX
+ # Import each parent in the name, starting at root.
+ # Skipping over details of constructing each parent name and setting the
+ # proper attribute on the parent for newly imported modules.
+ for parent in name:
+ if parent in sys.modules:
+ continue
+ for meta_importer in sys.meta_path:
+ check_meta_path(parent, meta_importer) # XXX
+ for path_entry in sys.path:
+ check_path(parent, path_entry) # XXX
+ # XXX error: not found
+ return module_to_return(path, fromlist) # XXX
More information about the Python-checkins
mailing list