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.
This commit is contained in:
parent
eed4c74a66
commit
5cf850f282
34
pep-0221.txt
34
pep-0221.txt
|
@ -3,7 +3,7 @@ Title: Import As
|
||||||
Version: $Revision$
|
Version: $Revision$
|
||||||
Author: thomas@xs4all.net (Thomas Wouters)
|
Author: thomas@xs4all.net (Thomas Wouters)
|
||||||
Status: Accepted
|
Status: Accepted
|
||||||
Type: Standard
|
Type: Standards Track
|
||||||
Python-Version: 2.0
|
Python-Version: 2.0
|
||||||
Created: 15-Aug-2000
|
Created: 15-Aug-2000
|
||||||
Post-History:
|
Post-History:
|
||||||
|
@ -49,16 +49,19 @@ Rationale
|
||||||
has to be used to convince the CPython parser it isn't one. For
|
has to be used to convince the CPython parser it isn't one. For
|
||||||
more advanced parsers/tokenizers, however, this should not be a
|
more advanced parsers/tokenizers, however, this should not be a
|
||||||
problem.
|
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
|
import os.path as p
|
||||||
not allowed. When importing a submodule in the normal way,
|
|
||||||
|
should store `os.path', not `os', in `p'. The current
|
||||||
import os.path
|
implementation does not yet support this.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
|
||||||
Implementation details
|
Implementation details
|
||||||
|
@ -85,15 +88,8 @@ Implementation details
|
||||||
change to accomodate this is minimal, as the patch proves[2], and
|
change to accomodate this is minimal, as the patch proves[2], and
|
||||||
the resulting generalization allows a number of new constructs
|
the resulting generalization allows a number of new constructs
|
||||||
that run completely parallel with other Python assignment
|
that run completely parallel with other Python assignment
|
||||||
constructs.
|
constructs. However, this idea has been rejected by Guido, as
|
||||||
|
`hypergeneralization'.
|
||||||
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:]
|
|
||||||
|
|
||||||
|
|
||||||
Copyright
|
Copyright
|
||||||
|
|
Loading…
Reference in New Issue