• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1:mod:`importlib` --- Convenience wrappers for :func:`__import__`
2================================================================
3
4.. module:: importlib
5   :synopsis: Convenience wrappers for __import__
6
7.. moduleauthor:: Brett Cannon <brett@python.org>
8.. sectionauthor:: Brett Cannon <brett@python.org>
9
10.. versionadded:: 2.7
11
12This module is a minor subset of what is available in the more full-featured
13package of the same name from Python 3.1 that provides a complete
14implementation of :keyword:`import`. What is here has been provided to
15help ease in transitioning from 2.7 to 3.1.
16
17
18.. function:: import_module(name, package=None)
19
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.
28