[Python-checkins] peps: Clean up a few items: the 'import os.path as p' syntax and the

georg.brandl python-checkins at python.org
Wed Mar 23 21:26:37 CET 2011


http://hg.python.org/peps/rev/e3b977b7348a
changeset:   144:e3b977b7348a
user:        Thomas Wouters <thomas at python.org>
date:        Wed Aug 23 12:09:07 2000 +0000
summary:
  Clean up a few items: the 'import os.path as p' syntax and the
'extended-as'-assignment syntax, both of which Guido has decided on.

files:
  pep-0221.txt |  34 +++++++++++++++-------------------
  1 files changed, 15 insertions(+), 19 deletions(-)


diff --git a/pep-0221.txt b/pep-0221.txt
--- a/pep-0221.txt
+++ b/pep-0221.txt
@@ -3,7 +3,7 @@
 Version: $Revision$
 Author: thomas at xs4all.net (Thomas Wouters)
 Status: Accepted
-Type: Standard
+Type: Standards Track
 Python-Version: 2.0
 Created: 15-Aug-2000
 Post-History:
@@ -49,16 +49,19 @@
     has to be used to convince the CPython parser it isn't one.  For
     more advanced parsers/tokenizers, however, this should not be a
     problem.
+
+    A slightly special case exists for importing sub-modules.  The
+    statement
+
+        import os.path    
+
+    stores the module `os' locally as `os', so that the imported
+    submodule `path' is accessible as `os.path'.  As a result,
     
-    To avoid confusion, importing a submodule `as' another module is
-    not allowed. When importing a submodule in the normal way,
-    
-        import os.path
-        
-    The actual name stored locally is `os', not `path', and the newly
-    imported module can be referenced as `os.path'.  When introducing
-    the `as' keyword, it is unclear whether the `os' module or the
-    `path' sub-module should be stored `as' the requested local name.
+        import os.path as p
+
+    should store `os.path', not `os', in `p'.  The current
+    implementation does not yet support this.
 
 
 Implementation details
@@ -85,15 +88,8 @@
     change to accomodate this is minimal, as the patch proves[2], and
     the resulting generalization allows a number of new constructs
     that run completely parallel with other Python assignment
-    constructs.
-
-        import sys as x['sys']
-
-        from MyFastcPickle import Pickler as shelve.Pickler
-        
-        from sys import version_info as (maj, min, pl, relnam, relno)
-        
-        from sys import path as mypath[-1:]
+    constructs. However, this idea has been rejected by Guido, as
+    `hypergeneralization'.
 
 
 Copyright

-- 
Repository URL: http://hg.python.org/peps


More information about the Python-checkins mailing list