Issue #5262: Improved fix.
[python.git] / Doc / library / importlib.rst
blob375c2ae918e637b31b49b1c7bb66fc41829aaea0
1 :mod:`importlib` -- Convenience wrappers for :func:`__import__`
2 ===============================================================
4 .. module:: importlib
5    :synopsis: Convenience wrappers for __import__
7 .. moduleauthor:: Brett Cannon <brett@python.org>
8 .. sectionauthor:: Brett Cannon <brett@python.org>
10 .. versionadded:: 2.7
12 This module is a minor subset of what is available in the more full-featured
13 package of the same name from Python 3.1 that provides a complete
14 implementation of :keyword:`import`. What is here has been provided to
15 help ease in transitioning from 2.7 to 3.1.
18 .. function:: import_module(name, package=None)
20     Import a module. The *name* argument specifies what module to
21     import in absolute or relative terms
22     (e.g. either ``pkg.mod`` or ``..mod``). If the name is
23     specified in relative terms, then the *package* argument must be
24     specified to the package which is to act as the anchor for resolving the
25     package name (e.g. ``import_module('..mod', 'pkg.subpkg')`` will import
26     ``pkg.mod``). The specified module will be inserted into
27     :data:`sys.modules` and returned.