summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBrett Cannon <brett@python.org>2015-02-20 15:34:20 (GMT)
committerBrett Cannon <brett@python.org>2015-02-20 15:34:20 (GMT)
commit3fa84224fd6c0e55185f5c19c318a87bb7762f30 (patch)
treebcd53abeed730342cbda226750503568046d1c3d /Doc
parent16cd19c8a2c7ceaa03312836003e40fc79915161 (diff)
downloadcpython-3fa84224fd6c0e55185f5c19c318a87bb7762f30.zip
cpython-3fa84224fd6c0e55185f5c19c318a87bb7762f30.tar.gz
cpython-3fa84224fd6c0e55185f5c19c318a87bb7762f30.tar.bz2
Issue #23422: Clarify some things around importlib.import_module()
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/importlib.rst19
1 files changed, 13 insertions, 6 deletions
diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst
index 9c6b280..e61ac35 100644
--- a/Doc/library/importlib.rst
+++ b/Doc/library/importlib.rst
@@ -69,6 +69,10 @@ Functions
An implementation of the built-in :func:`__import__` function.
+ .. note::
+ Programmatic importing of modules should use :func:`import_module`
+ instead of this function.
+
.. function:: import_module(name, package=None)
Import a module. The *name* argument specifies what module to
@@ -81,12 +85,15 @@ Functions
The :func:`import_module` function acts as a simplifying wrapper around
:func:`importlib.__import__`. This means all semantics of the function are
- derived from :func:`importlib.__import__`, including requiring the package
- from which an import is occurring to have been previously imported
- (i.e., *package* must already be imported). The most important difference
- is that :func:`import_module` returns the specified package or module
- (e.g. ``pkg.mod``), while :func:`__import__` returns the
- top-level package or module (e.g. ``pkg``).
+ derived from :func:`importlib.__import__`. The most important difference
+ between these two functions is that :func:`import_module` returns the
+ specified package or module (e.g. ``pkg.mod``), while :func:`__import__`
+ returns the top-level package or module (e.g. ``pkg``).
+
+ If you are dynamically importing a module that was created since the
+ interpreter began execution (e.g., created a Python source file), you may
+ need to call :func:`invalidate_caches` in order for the new module to be
+ noticed by the import system.
.. versionchanged:: 3.3
Parent packages are automatically imported.