summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2011-07-29 15:50:58 (GMT)
committerÉric Araujo <merwok@netwok.org>2011-07-29 15:50:58 (GMT)
commite801aa2a1d291635b3607bc424c639a992799254 (patch)
treeedb3d3b65f45c6e182c34f49d50aa559ffc86399 /Doc/library
parente64e51bfa78cd8ec046e187a3214cd9d477fc65c (diff)
downloadcpython-e801aa2a1d291635b3607bc424c639a992799254.zip
cpython-e801aa2a1d291635b3607bc424c639a992799254.tar.gz
cpython-e801aa2a1d291635b3607bc424c639a992799254.tar.bz2
Let the doc of __import__ link to importlib (#9254).
importlib.import_module eschews a number of issues that __import__ has. Reviewed by Brett Cannon. (The docstring of __import__ was already updated in 3d490c3a019e, for #7397.)
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/functions.rst13
1 files changed, 3 insertions, 10 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index b766a2e..edff106 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1387,7 +1387,7 @@ are always available. They are listed here in alphabetical order.
.. note::
This is an advanced function that is not needed in everyday Python
- programming.
+ programming, unlike :func:`importlib.import_module`.
This function is invoked by the :keyword:`import` statement. It can be
replaced (by importing the :mod:`builtins` module and assigning to
@@ -1437,15 +1437,8 @@ are always available. They are listed here in alphabetical order.
names.
If you simply want to import a module (potentially within a package) by name,
- you can call :func:`__import__` and then look it up in :data:`sys.modules`::
-
- >>> import sys
- >>> name = 'foo.bar.baz'
- >>> __import__(name)
- <module 'foo' from ...>
- >>> baz = sys.modules[name]
- >>> baz
- <module 'foo.bar.baz' from ...>
+ use :func:`importlib.import_module`.
+
.. rubric:: Footnotes