Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98620d8

Browse files
committed
Issue #19963: Document that importlib.import_module() will import
parent packages automatically.
1 parent d913d9d commit 98620d8

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Doc/library/importlib.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,13 @@ Functions
8282
derived from :func:`importlib.__import__`, including requiring the package
8383
from which an import is occurring to have been previously imported
8484
(i.e., *package* must already be imported). The most important difference
85-
is that :func:`import_module` returns the most nested package or module
86-
that was imported (e.g. ``pkg.mod``), while :func:`__import__` returns the
85+
is that :func:`import_module` returns the specified package or module
86+
(e.g. ``pkg.mod``), while :func:`__import__` returns the
8787
top-level package or module (e.g. ``pkg``).
8888

89+
.. versionchanged:: 3.3
90+
Parent packages are automatically imported.
91+
8992
.. function:: find_loader(name, path=None)
9093

9194
Find the loader for a module, optionally within the specified *path*. If the

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ Tests
169169
Documentation
170170
-------------
171171

172+
- Issue #19963: Document that importlib.import_module() no longer requires
173+
importing parent packages separately.
174+
172175
- Issue #18840: Introduce the json module in the tutorial, and deemphasize
173176
the pickle module.
174177

0 commit comments

Comments
 (0)