Correct versions since this PEP was not implemented in 2.4
This commit is contained in:
parent
dcbb9e2182
commit
f42160765a
16
pep-0328.txt
16
pep-0328.txt
|
@ -5,7 +5,7 @@ Last-Modified: $Date$
|
|||
Author: Aahz <aahz@pythoncraft.com>
|
||||
Status: Accepted
|
||||
Type: Standards Track
|
||||
Python-Version: 2.4, 2,5, 2.6
|
||||
Python-Version: 2.4, 2,5, 2.6, 2.7
|
||||
Content-Type: text/x-rst
|
||||
Created: 21-Dec-2003
|
||||
Post-History: 8-Mar-2004
|
||||
|
@ -36,14 +36,14 @@ imports.
|
|||
Timeline
|
||||
========
|
||||
|
||||
In Python 2.4, you must enable the new absolute import behavior with ::
|
||||
In Python 2.5, you must enable the new absolute import behavior with ::
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
You may use relative imports freely. In Python 2.5, any ``import``
|
||||
You may use relative imports freely. In Python 2.6, any ``import``
|
||||
statement that results in an intra-package import will raise
|
||||
``DeprecationWarning`` (this also applies to ``from <> import`` that
|
||||
fails to use the relative import syntax). In Python 2.6, ``import`` will
|
||||
fails to use the relative import syntax). In Python 2.7, ``import`` will
|
||||
always be an absolute import (and the ``__future__`` directive will no
|
||||
longer be needed).
|
||||
|
||||
|
@ -74,11 +74,13 @@ mechanism (parentheses) to write the ``import`` statement::
|
|||
|
||||
This part of the proposal had BDFL approval from the beginning.
|
||||
|
||||
Parentheses support was added to Python 2.4.
|
||||
|
||||
|
||||
Rationale for Absolute Imports
|
||||
==============================
|
||||
|
||||
In Python 2.3 and earlier, if you're reading a module located inside a
|
||||
In Python 2.4 and earlier, if you're reading a module located inside a
|
||||
package, it is not clear whether ::
|
||||
|
||||
import foo
|
||||
|
@ -98,7 +100,7 @@ the cost of difficulty when renaming package pieces higher up in the
|
|||
hierarchy or when moving one package inside another.
|
||||
|
||||
Because this represents a change in semantics, absolute imports will
|
||||
be optional in Python 2.4 and 2.5 through the use of ::
|
||||
be optional in Python 2.5 and 2.6 through the use of ::
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
|
@ -192,7 +194,7 @@ Here are the contenders:
|
|||
import NAMES as RENAME from MODULE searching HOW
|
||||
[from NAMES] [in WHERE] import ...
|
||||
|
||||
However, this most likely could not be implemented for Python 2.4
|
||||
However, this most likely could not be implemented for Python 2.5
|
||||
(too big a change), and allowing relative imports is sufficiently
|
||||
critical that we need something now (given that the standard
|
||||
``import`` will change to absolute import). More than that, this
|
||||
|
|
Loading…
Reference in New Issue