[Python-checkins] cpython (3.2): Let the doc of __import__ link to importlib (#9254).

eric.araujo python-checkins at python.org
Fri Jul 29 18:11:12 CEST 2011


http://hg.python.org/cpython/rev/7bfc0a45542c
changeset:   71602:7bfc0a45542c
branch:      3.2
parent:      71600:f02a8f906342
user:        Éric Araujo <merwok at netwok.org>
date:        Fri Jul 29 17:50:58 2011 +0200
summary:
  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.)

files:
  Doc/library/functions.rst |  11 ++---------
  1 files changed, 2 insertions(+), 9 deletions(-)


diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -1387,7 +1387,7 @@
    .. 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 @@
    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`::
+   use :func:`importlib.import_module`.
 
-      >>> import sys
-      >>> name = 'foo.bar.baz'
-      >>> __import__(name)
-      <module 'foo' from ...>
-      >>> baz = sys.modules[name]
-      >>> baz
-      <module 'foo.bar.baz' from ...>
 
 .. rubric:: Footnotes
 

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


More information about the Python-checkins mailing list