diff options
Diffstat (limited to 'Doc/library/functions.rst')
-rw-r--r-- | Doc/library/functions.rst | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index a324e51..dc8ee9a 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1558,7 +1558,7 @@ 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:`__builtin__` module and assigning to @@ -1609,15 +1609,8 @@ 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`. + .. versionchanged:: 2.5 The level parameter was added. |