From 4fcf1df9575cdcee648b38b8603f16c7c0aa1e98 Mon Sep 17 00:00:00 2001 From: Alexey Shrub Date: Fri, 29 Nov 2019 09:54:08 +0300 Subject: [PATCH] Add return value type of import functions to docs --- Doc/library/functions.rst | 2 ++ Doc/library/importlib.rst | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 28b9649a163..69e0f66dee4 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1775,6 +1775,8 @@ are always available. They are listed here in alphabetical order. goals and does not cause issues with code which assumes the default import implementation is in use. Direct use of :func:`__import__` is also discouraged in favor of :func:`importlib.import_module`. + Usually function returns :class:`types.ModuleType` object, but no guarantees + for that. If nothing found :exc:`ModuleNotFoundError` will be raised. The function imports the module *name*, potentially using the given *globals* and *locals* to determine how to interpret the name in a package context. diff --git a/Doc/library/importlib.rst b/Doc/library/importlib.rst index cfde3a47f75..8f7beb36c57 100644 --- a/Doc/library/importlib.rst +++ b/Doc/library/importlib.rst @@ -90,9 +90,9 @@ Functions .. function:: import_module(name, package=None) - Import a module. The *name* argument specifies what module to - import in absolute or relative terms - (e.g. either ``pkg.mod`` or ``..mod``). If the name is + Import a module, for return value information see :func:`__import__`. + The *name* argument specifies what module to import in absolute or + relative terms (e.g. either ``pkg.mod`` or ``..mod``). If the name is specified in relative terms, then the *package* argument must be set to the name of the package which is to act as the anchor for resolving the package name (e.g. ``import_module('..mod', 'pkg.subpkg')`` will import