summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2012-04-15 01:58:33 (GMT)
committerBrett Cannon <brett@python.org>2012-04-15 01:58:33 (GMT)
commit2a082add9d26f280a889fb5043910bf56df84a6a (patch)
tree2f7b37fd5608a707026f5f3f23fcc58d84006906
parent49f8d8b016b030b7501ce8dc2babe5dfc14985e9 (diff)
downloadcpython-2a082add9d26f280a889fb5043910bf56df84a6a.zip
cpython-2a082add9d26f280a889fb5043910bf56df84a6a.tar.gz
cpython-2a082add9d26f280a889fb5043910bf56df84a6a.tar.bz2
Clarify that one should not use __import__() directly. Also mention
PEP 328 in explaining how 'index' works.
-rw-r--r--Doc/library/functions.rst8
1 files changed, 5 insertions, 3 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index 2674ef9..9287bfb 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1447,8 +1447,9 @@ are always available. They are listed here in alphabetical order.
replaced (by importing the :mod:`builtins` module and assigning to
``builtins.__import__``) in order to change semantics of the
:keyword:`import` statement, but nowadays it is usually simpler to use import
- hooks (see :pep:`302`). Direct use of :func:`__import__` is rare, except in
- cases where you want to import a module whose name is only known at runtime.
+ hooks (see :pep:`302`) to attain the same goals. Direct use of
+ :func:`__import__` is entirely discouraged in favor of
+ :func:`importlib.import_module`.
The function imports the module *name*, potentially using the given *globals*
and *locals* to determine how to interpret the name in a package context.
@@ -1460,7 +1461,8 @@ are always available. They are listed here in alphabetical order.
*level* specifies whether to use absolute or relative imports. ``0`` (the
default) means only perform absolute imports. Positive values for
*level* indicate the number of parent directories to search relative to the
- directory of the module calling :func:`__import__`.
+ directory of the module calling :func:`__import__` (see :pep:`328` for the
+ details).
When the *name* variable is of the form ``package.module``, normally, the
top-level package (the name up till the first dot) is returned, *not* the