\!/ KyuuKazami \!/

Path : /usr/share/doc/python34-docs-3.4.3/library/
Upload :
Current File : //usr/share/doc/python34-docs-3.4.3/library/importlib.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>31.5. importlib – The implementation of import &mdash; Python 3.4.3 documentation</title>
    
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '3.4.3',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.4.3 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="top" title="Python 3.4.3 documentation" href="../index.html" />
    <link rel="up" title="31. Importing Modules" href="modules.html" />
    <link rel="next" title="32. Python Language Services" href="language.html" />
    <link rel="prev" title="31.4. runpy — Locating and executing Python modules" href="runpy.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    
    
 

  </head>
  <body>  
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="language.html" title="32. Python Language Services"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="runpy.html" title="31.4. runpy — Locating and executing Python modules"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
        <li>
          <a href="../index.html">3.4.3 Documentation</a> &raquo;
        </li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="modules.html" accesskey="U">31. Importing Modules</a> &raquo;</li> 
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-importlib">
<span id="importlib-the-implementation-of-import"></span><h1>31.5. <a class="reference internal" href="#module-importlib" title="importlib: The implementation of the import machinery."><tt class="xref py py-mod docutils literal"><span class="pre">importlib</span></tt></a> &#8211; The implementation of <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a><a class="headerlink" href="#module-importlib" title="Permalink to this headline">¶</a></h1>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.1.</span></p>
</div>
<div class="section" id="introduction">
<h2>31.5.1. Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>The purpose of the <a class="reference internal" href="#module-importlib" title="importlib: The implementation of the import machinery."><tt class="xref py py-mod docutils literal"><span class="pre">importlib</span></tt></a> package is two-fold. One is to provide the
implementation of the <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a> statement (and thus, by extension, the
<a class="reference internal" href="functions.html#__import__" title="__import__"><tt class="xref py py-func docutils literal"><span class="pre">__import__()</span></tt></a> function) in Python source code. This provides an
implementation of <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a> which is portable to any Python
interpreter. This also provides an implementation which is easier to
comprehend than one implemented in a programming language other than Python.</p>
<p>Two, the components to implement <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a> are exposed in this
package, making it easier for users to create their own custom objects (known
generically as an <a class="reference internal" href="../glossary.html#term-importer"><em class="xref std std-term">importer</em></a>) to participate in the import process.</p>
<div class="admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt><a class="reference internal" href="../reference/simple_stmts.html#import"><em>The import statement</em></a></dt>
<dd>The language reference for the <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a> statement.</dd>
<dt><a class="reference external" href="http://legacy.python.org/doc/essays/packages.html">Packages specification</a></dt>
<dd>Original specification of packages. Some semantics have changed since
the writing of this document (e.g. redirecting based on <tt class="docutils literal"><span class="pre">None</span></tt>
in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a>).</dd>
<dt>The <a class="reference internal" href="#importlib.__import__" title="importlib.__import__"><tt class="xref py py-func docutils literal"><span class="pre">__import__()</span></tt></a> function</dt>
<dd>The <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a> statement is syntactic sugar for this function.</dd>
<dt><span class="target" id="index-0"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0235"><strong>PEP 235</strong></a></dt>
<dd>Import on Case-Insensitive Platforms</dd>
<dt><span class="target" id="index-1"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0263"><strong>PEP 263</strong></a></dt>
<dd>Defining Python Source Code Encodings</dd>
<dt><span class="target" id="index-2"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a></dt>
<dd>New Import Hooks</dd>
<dt><span class="target" id="index-3"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0328"><strong>PEP 328</strong></a></dt>
<dd>Imports: Multi-Line and Absolute/Relative</dd>
<dt><span class="target" id="index-4"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0366"><strong>PEP 366</strong></a></dt>
<dd>Main module explicit relative imports</dd>
<dt><span class="target" id="index-5"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0451"><strong>PEP 451</strong></a></dt>
<dd>A ModuleSpec Type for the Import System</dd>
<dt><span class="target" id="index-6"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-3120"><strong>PEP 3120</strong></a></dt>
<dd>Using UTF-8 as the Default Source Encoding</dd>
<dt><span class="target" id="index-7"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-3147"><strong>PEP 3147</strong></a></dt>
<dd>PYC Repository Directories</dd>
</dl>
</div>
</div>
<div class="section" id="functions">
<h2>31.5.2. Functions<a class="headerlink" href="#functions" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="importlib.__import__">
<tt class="descclassname">importlib.</tt><tt class="descname">__import__</tt><big>(</big><em>name</em>, <em>globals=None</em>, <em>locals=None</em>, <em>fromlist=()</em>, <em>level=0</em><big>)</big><a class="headerlink" href="#importlib.__import__" title="Permalink to this definition">¶</a></dt>
<dd><p>An implementation of the built-in <a class="reference internal" href="functions.html#__import__" title="__import__"><tt class="xref py py-func docutils literal"><span class="pre">__import__()</span></tt></a> function.</p>
</dd></dl>

<dl class="function">
<dt id="importlib.import_module">
<tt class="descclassname">importlib.</tt><tt class="descname">import_module</tt><big>(</big><em>name</em>, <em>package=None</em><big>)</big><a class="headerlink" href="#importlib.import_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Import a module. The <em>name</em> argument specifies what module to
import in absolute or relative terms
(e.g. either <tt class="docutils literal"><span class="pre">pkg.mod</span></tt> or <tt class="docutils literal"><span class="pre">..mod</span></tt>). If the name is
specified in relative terms, then the <em>package</em> argument must be set to
the name of the package which is to act as the anchor for resolving the
package name (e.g. <tt class="docutils literal"><span class="pre">import_module('..mod',</span> <span class="pre">'pkg.subpkg')</span></tt> will import
<tt class="docutils literal"><span class="pre">pkg.mod</span></tt>).</p>
<p>The <a class="reference internal" href="#importlib.import_module" title="importlib.import_module"><tt class="xref py py-func docutils literal"><span class="pre">import_module()</span></tt></a> function acts as a simplifying wrapper around
<a class="reference internal" href="#importlib.__import__" title="importlib.__import__"><tt class="xref py py-func docutils literal"><span class="pre">importlib.__import__()</span></tt></a>. This means all semantics of the function are
derived from <a class="reference internal" href="#importlib.__import__" title="importlib.__import__"><tt class="xref py py-func docutils literal"><span class="pre">importlib.__import__()</span></tt></a>, including requiring the package
from which an import is occurring to have been previously imported
(i.e., <em>package</em> must already be imported). The most important difference
is that <a class="reference internal" href="#importlib.import_module" title="importlib.import_module"><tt class="xref py py-func docutils literal"><span class="pre">import_module()</span></tt></a> returns the specified package or module
(e.g. <tt class="docutils literal"><span class="pre">pkg.mod</span></tt>), while <a class="reference internal" href="functions.html#__import__" title="__import__"><tt class="xref py py-func docutils literal"><span class="pre">__import__()</span></tt></a> returns the
top-level package or module (e.g. <tt class="docutils literal"><span class="pre">pkg</span></tt>).</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.3: </span>Parent packages are automatically imported.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.find_loader">
<tt class="descclassname">importlib.</tt><tt class="descname">find_loader</tt><big>(</big><em>name</em>, <em>path=None</em><big>)</big><a class="headerlink" href="#importlib.find_loader" title="Permalink to this definition">¶</a></dt>
<dd><p>Find the loader for a module, optionally within the specified <em>path</em>. If the
module is in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-attr docutils literal"><span class="pre">sys.modules</span></tt></a>, then <tt class="docutils literal"><span class="pre">sys.modules[name].__loader__</span></tt> is
returned (unless the loader would be <tt class="docutils literal"><span class="pre">None</span></tt> or is not set, in which case
<a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> is raised). Otherwise a search using <a class="reference internal" href="sys.html#sys.meta_path" title="sys.meta_path"><tt class="xref py py-attr docutils literal"><span class="pre">sys.meta_path</span></tt></a>
is done. <tt class="docutils literal"><span class="pre">None</span></tt> is returned if no loader is found.</p>
<p>A dotted name does not have its parent&#8217;s implicitly imported as that requires
loading them and that may not be desired. To properly import a submodule you
will need to import all parent packages of the submodule and use the correct
argument to <em>path</em>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>If <tt class="docutils literal"><span class="pre">__loader__</span></tt> is not set, raise <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a>, just like when the
attribute is set to <tt class="docutils literal"><span class="pre">None</span></tt>.</p>
</div>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>Use <a class="reference internal" href="#importlib.util.find_spec" title="importlib.util.find_spec"><tt class="xref py py-func docutils literal"><span class="pre">importlib.util.find_spec()</span></tt></a> instead.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.invalidate_caches">
<tt class="descclassname">importlib.</tt><tt class="descname">invalidate_caches</tt><big>(</big><big>)</big><a class="headerlink" href="#importlib.invalidate_caches" title="Permalink to this definition">¶</a></dt>
<dd><p>Invalidate the internal caches of finders stored at
<a class="reference internal" href="sys.html#sys.meta_path" title="sys.meta_path"><tt class="xref py py-data docutils literal"><span class="pre">sys.meta_path</span></tt></a>. If a finder implements <tt class="docutils literal"><span class="pre">invalidate_caches()</span></tt> then it
will be called to perform the invalidation.  This function should be called
if any modules are created/installed while your program is running to
guarantee all finders will notice the new module&#8217;s existence.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.reload">
<tt class="descclassname">importlib.</tt><tt class="descname">reload</tt><big>(</big><em>module</em><big>)</big><a class="headerlink" href="#importlib.reload" title="Permalink to this definition">¶</a></dt>
<dd><p>Reload a previously imported <em>module</em>.  The argument must be a module object,
so it must have been successfully imported before.  This is useful if you
have edited the module source file using an external editor and want to try
out the new version without leaving the Python interpreter.  The return value
is the module object (which can be different if re-importing causes a
different object to be placed in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a>).</p>
<p>When <a class="reference internal" href="#importlib.reload" title="importlib.reload"><tt class="xref py py-func docutils literal"><span class="pre">reload()</span></tt></a> is executed:</p>
<ul class="simple">
<li>Python module&#8217;s code is recompiled and the module-level code re-executed,
defining a new set of objects which are bound to names in the module&#8217;s
dictionary by reusing the <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a> which originally loaded the
module.  The <tt class="docutils literal"><span class="pre">init</span></tt> function of extension modules is not called a second
time.</li>
<li>As with all other objects in Python the old objects are only reclaimed
after their reference counts drop to zero.</li>
<li>The names in the module namespace are updated to point to any new or
changed objects.</li>
<li>Other references to the old objects (such as names external to the module) are
not rebound to refer to the new objects and must be updated in each namespace
where they occur if that is desired.</li>
</ul>
<p>There are a number of other caveats:</p>
<p>If a module is syntactically correct but its initialization fails, the first
<a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a> statement for it does not bind its name locally, but does
store a (partially initialized) module object in <tt class="docutils literal"><span class="pre">sys.modules</span></tt>.  To reload
the module you must first <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a> it again (this will bind the name
to the partially initialized module object) before you can <a class="reference internal" href="#importlib.reload" title="importlib.reload"><tt class="xref py py-func docutils literal"><span class="pre">reload()</span></tt></a> it.</p>
<p>When a module is reloaded, its dictionary (containing the module&#8217;s global
variables) is retained.  Redefinitions of names will override the old
definitions, so this is generally not a problem.  If the new version of a
module does not define a name that was defined by the old version, the old
definition remains.  This feature can be used to the module&#8217;s advantage if it
maintains a global table or cache of objects &#8212; with a <a class="reference internal" href="../reference/compound_stmts.html#try"><tt class="xref std std-keyword docutils literal"><span class="pre">try</span></tt></a>
statement it can test for the table&#8217;s presence and skip its initialization if
desired:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="k">try</span><span class="p">:</span>
    <span class="n">cache</span>
<span class="k">except</span> <span class="ne">NameError</span><span class="p">:</span>
    <span class="n">cache</span> <span class="o">=</span> <span class="p">{}</span>
</pre></div>
</div>
<p>It is legal though generally not very useful to reload built-in or
dynamically loaded modules (this is not true for e.g. <a class="reference internal" href="sys.html#module-sys" title="sys: Access system-specific parameters and functions."><tt class="xref py py-mod docutils literal"><span class="pre">sys</span></tt></a>,
<a class="reference internal" href="__main__.html#module-__main__" title="__main__: The environment where the top-level script is run."><tt class="xref py py-mod docutils literal"><span class="pre">__main__</span></tt></a>, <a class="reference internal" href="builtins.html#module-builtins" title="builtins: The module that provides the built-in namespace."><tt class="xref py py-mod docutils literal"><span class="pre">builtins</span></tt></a> and other key modules where reloading is
frowned upon). In many cases, however, extension modules are not designed to
be initialized more than once, and may fail in arbitrary ways when reloaded.</p>
<p>If a module imports objects from another module using <a class="reference internal" href="../reference/simple_stmts.html#from"><tt class="xref std std-keyword docutils literal"><span class="pre">from</span></tt></a> ...
<a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a> ..., calling <a class="reference internal" href="#importlib.reload" title="importlib.reload"><tt class="xref py py-func docutils literal"><span class="pre">reload()</span></tt></a> for the other module does not
redefine the objects imported from it &#8212; one way around this is to
re-execute the <a class="reference internal" href="../reference/simple_stmts.html#from"><tt class="xref std std-keyword docutils literal"><span class="pre">from</span></tt></a> statement, another is to use <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a>
and qualified names (<em>module.name</em>) instead.</p>
<p>If a module instantiates instances of a class, reloading the module that
defines the class does not affect the method definitions of the instances &#8212;
they continue to use the old class definition.  The same is true for derived
classes.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

</div>
<div class="section" id="module-importlib.abc">
<span id="importlib-abc-abstract-base-classes-related-to-import"></span><h2>31.5.3. <a class="reference internal" href="#module-importlib.abc" title="importlib.abc: Abstract base classes related to import"><tt class="xref py py-mod docutils literal"><span class="pre">importlib.abc</span></tt></a> &#8211; Abstract base classes related to import<a class="headerlink" href="#module-importlib.abc" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#module-importlib.abc" title="importlib.abc: Abstract base classes related to import"><tt class="xref py py-mod docutils literal"><span class="pre">importlib.abc</span></tt></a> module contains all of the core abstract base classes
used by <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a>. Some subclasses of the core abstract base classes
are also provided to help in implementing the core ABCs.</p>
<p>ABC hierarchy:</p>
<div class="highlight-python3"><div class="highlight"><pre><span class="nb">object</span>
 <span class="o">+--</span> <span class="n">Finder</span> <span class="p">(</span><span class="n">deprecated</span><span class="p">)</span>
 <span class="o">|</span>    <span class="o">+--</span> <span class="n">MetaPathFinder</span>
 <span class="o">|</span>    <span class="o">+--</span> <span class="n">PathEntryFinder</span>
 <span class="o">+--</span> <span class="n">Loader</span>
      <span class="o">+--</span> <span class="n">ResourceLoader</span> <span class="o">--------+</span>
      <span class="o">+--</span> <span class="n">InspectLoader</span>          <span class="o">|</span>
           <span class="o">+--</span> <span class="n">ExecutionLoader</span> <span class="o">--+</span>
                                 <span class="o">+--</span> <span class="n">FileLoader</span>
                                 <span class="o">+--</span> <span class="n">SourceLoader</span>
</pre></div>
</div>
<dl class="class">
<dt id="importlib.abc.Finder">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">Finder</tt><a class="headerlink" href="#importlib.abc.Finder" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class representing a <a class="reference internal" href="../glossary.html#term-finder"><em class="xref std std-term">finder</em></a>.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.3: </span>Use <a class="reference internal" href="#importlib.abc.MetaPathFinder" title="importlib.abc.MetaPathFinder"><tt class="xref py py-class docutils literal"><span class="pre">MetaPathFinder</span></tt></a> or <a class="reference internal" href="#importlib.abc.PathEntryFinder" title="importlib.abc.PathEntryFinder"><tt class="xref py py-class docutils literal"><span class="pre">PathEntryFinder</span></tt></a> instead.</p>
</div>
<dl class="method">
<dt id="importlib.abc.Finder.find_module">
<tt class="descname">find_module</tt><big>(</big><em>fullname</em>, <em>path=None</em><big>)</big><a class="headerlink" href="#importlib.abc.Finder.find_module" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstact method for finding a <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a> for the specified
module.  Originally specified in <span class="target" id="index-8"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a>, this method was meant
for use in <a class="reference internal" href="sys.html#sys.meta_path" title="sys.meta_path"><tt class="xref py py-data docutils literal"><span class="pre">sys.meta_path</span></tt></a> and in the path-based import subsystem.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Returns <tt class="docutils literal"><span class="pre">None</span></tt> when called instead of raising
<a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.abc.MetaPathFinder">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">MetaPathFinder</tt><a class="headerlink" href="#importlib.abc.MetaPathFinder" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class representing a <a class="reference internal" href="../glossary.html#term-meta-path-finder"><em class="xref std std-term">meta path finder</em></a>. For
compatibility, this is a subclass of <a class="reference internal" href="#importlib.abc.Finder" title="importlib.abc.Finder"><tt class="xref py py-class docutils literal"><span class="pre">Finder</span></tt></a>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<dl class="method">
<dt id="importlib.abc.MetaPathFinder.find_spec">
<tt class="descname">find_spec</tt><big>(</big><em>fullname</em>, <em>path</em>, <em>target=None</em><big>)</big><a class="headerlink" href="#importlib.abc.MetaPathFinder.find_spec" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract method for finding a <a class="reference internal" href="../glossary.html#term-module-spec"><em class="xref std std-term">spec</em></a> for
the specified module.  If this is a top-level import, <em>path</em> will
be <tt class="docutils literal"><span class="pre">None</span></tt>.  Otherwise, this is a search for a subpackage or
module and <em>path</em> will be the value of <a class="reference internal" href="../reference/import.html#__path__" title="__path__"><tt class="xref py py-attr docutils literal"><span class="pre">__path__</span></tt></a> from the
parent package. If a spec cannot be found, <tt class="docutils literal"><span class="pre">None</span></tt> is returned.
When passed in, <tt class="docutils literal"><span class="pre">target</span></tt> is a module object that the finder may
use to make a more educated about what spec to return.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.MetaPathFinder.find_module">
<tt class="descname">find_module</tt><big>(</big><em>fullname</em>, <em>path</em><big>)</big><a class="headerlink" href="#importlib.abc.MetaPathFinder.find_module" title="Permalink to this definition">¶</a></dt>
<dd><p>A legacy method for finding a <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a> for the specified
module.  If this is a top-level import, <em>path</em> will be <tt class="docutils literal"><span class="pre">None</span></tt>.
Otherwise, this is a search for a subpackage or module and <em>path</em>
will be the value of <a class="reference internal" href="../reference/import.html#__path__" title="__path__"><tt class="xref py py-attr docutils literal"><span class="pre">__path__</span></tt></a> from the parent
package. If a loader cannot be found, <tt class="docutils literal"><span class="pre">None</span></tt> is returned.</p>
<p>If <a class="reference internal" href="#importlib.abc.MetaPathFinder.find_spec" title="importlib.abc.MetaPathFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a> is defined, backwards-compatible functionality is
provided.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Returns <tt class="docutils literal"><span class="pre">None</span></tt> when called instead of raising
<a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>. Can use <a class="reference internal" href="#importlib.abc.MetaPathFinder.find_spec" title="importlib.abc.MetaPathFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a> to provide
functionality.</p>
</div>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>Use <a class="reference internal" href="#importlib.abc.MetaPathFinder.find_spec" title="importlib.abc.MetaPathFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a> instead.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.MetaPathFinder.invalidate_caches">
<tt class="descname">invalidate_caches</tt><big>(</big><big>)</big><a class="headerlink" href="#importlib.abc.MetaPathFinder.invalidate_caches" title="Permalink to this definition">¶</a></dt>
<dd><p>An optional method which, when called, should invalidate any internal
cache used by the finder. Used by <a class="reference internal" href="#importlib.invalidate_caches" title="importlib.invalidate_caches"><tt class="xref py py-func docutils literal"><span class="pre">importlib.invalidate_caches()</span></tt></a>
when invalidating the caches of all finders on <a class="reference internal" href="sys.html#sys.meta_path" title="sys.meta_path"><tt class="xref py py-data docutils literal"><span class="pre">sys.meta_path</span></tt></a>.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Returns <tt class="docutils literal"><span class="pre">None</span></tt> when called instead of <tt class="docutils literal"><span class="pre">NotImplemented</span></tt>.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.abc.PathEntryFinder">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">PathEntryFinder</tt><a class="headerlink" href="#importlib.abc.PathEntryFinder" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class representing a <a class="reference internal" href="../glossary.html#term-path-entry-finder"><em class="xref std std-term">path entry finder</em></a>.  Though
it bears some similarities to <a class="reference internal" href="#importlib.abc.MetaPathFinder" title="importlib.abc.MetaPathFinder"><tt class="xref py py-class docutils literal"><span class="pre">MetaPathFinder</span></tt></a>, <tt class="docutils literal"><span class="pre">PathEntryFinder</span></tt>
is meant for use only within the path-based import subsystem provided
by <tt class="xref py py-class docutils literal"><span class="pre">PathFinder</span></tt>. This ABC is a subclass of <a class="reference internal" href="#importlib.abc.Finder" title="importlib.abc.Finder"><tt class="xref py py-class docutils literal"><span class="pre">Finder</span></tt></a> for
compatibility reasons only.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<dl class="method">
<dt id="importlib.abc.PathEntryFinder.find_spec">
<tt class="descname">find_spec</tt><big>(</big><em>fullname</em>, <em>target=None</em><big>)</big><a class="headerlink" href="#importlib.abc.PathEntryFinder.find_spec" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract method for finding a <a class="reference internal" href="../glossary.html#term-module-spec"><em class="xref std std-term">spec</em></a> for
the specified module.  The finder will search for the module only
within the <a class="reference internal" href="../glossary.html#term-path-entry"><em class="xref std std-term">path entry</em></a> to which it is assigned.  If a spec
cannot be found, <tt class="docutils literal"><span class="pre">None</span></tt> is returned.  When passed in, <tt class="docutils literal"><span class="pre">target</span></tt>
is a module object that the finder may use to make a more educated
about what spec to return.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.PathEntryFinder.find_loader">
<tt class="descname">find_loader</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.PathEntryFinder.find_loader" title="Permalink to this definition">¶</a></dt>
<dd><p>A legacy method for finding a <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a> for the specified
module.  Returns a 2-tuple of <tt class="docutils literal"><span class="pre">(loader,</span> <span class="pre">portion)</span></tt> where <tt class="docutils literal"><span class="pre">portion</span></tt>
is a sequence of file system locations contributing to part of a namespace
package. The loader may be <tt class="docutils literal"><span class="pre">None</span></tt> while specifying <tt class="docutils literal"><span class="pre">portion</span></tt> to
signify the contribution of the file system locations to a namespace
package. An empty list can be used for <tt class="docutils literal"><span class="pre">portion</span></tt> to signify the loader
is not part of a namespace package. If <tt class="docutils literal"><span class="pre">loader</span></tt> is <tt class="docutils literal"><span class="pre">None</span></tt> and
<tt class="docutils literal"><span class="pre">portion</span></tt> is the empty list then no loader or location for a namespace
package were found (i.e. failure to find anything for the module).</p>
<p>If <a class="reference internal" href="#importlib.abc.PathEntryFinder.find_spec" title="importlib.abc.PathEntryFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a> is defined then backwards-compatible functionality is
provided.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Returns <tt class="docutils literal"><span class="pre">(None,</span> <span class="pre">[])</span></tt> instead of raising <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>.
Uses <a class="reference internal" href="#importlib.abc.PathEntryFinder.find_spec" title="importlib.abc.PathEntryFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a> when available to provide functionality.</p>
</div>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>Use <a class="reference internal" href="#importlib.abc.PathEntryFinder.find_spec" title="importlib.abc.PathEntryFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a> instead.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.PathEntryFinder.find_module">
<tt class="descname">find_module</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.PathEntryFinder.find_module" title="Permalink to this definition">¶</a></dt>
<dd><p>A concrete implementation of <a class="reference internal" href="#importlib.abc.Finder.find_module" title="importlib.abc.Finder.find_module"><tt class="xref py py-meth docutils literal"><span class="pre">Finder.find_module()</span></tt></a> which is
equivalent to <tt class="docutils literal"><span class="pre">self.find_loader(fullname)[0]</span></tt>.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>Use <a class="reference internal" href="#importlib.abc.PathEntryFinder.find_spec" title="importlib.abc.PathEntryFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a> instead.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.PathEntryFinder.invalidate_caches">
<tt class="descname">invalidate_caches</tt><big>(</big><big>)</big><a class="headerlink" href="#importlib.abc.PathEntryFinder.invalidate_caches" title="Permalink to this definition">¶</a></dt>
<dd><p>An optional method which, when called, should invalidate any internal
cache used by the finder. Used by <tt class="xref py py-meth docutils literal"><span class="pre">PathFinder.invalidate_caches()</span></tt>
when invalidating the caches of all cached finders.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.abc.Loader">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">Loader</tt><a class="headerlink" href="#importlib.abc.Loader" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class for a <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a>.
See <span class="target" id="index-9"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a> for the exact definition for a loader.</p>
<dl class="method">
<dt id="importlib.abc.Loader.create_module">
<tt class="descname">create_module</tt><big>(</big><em>spec</em><big>)</big><a class="headerlink" href="#importlib.abc.Loader.create_module" title="Permalink to this definition">¶</a></dt>
<dd><p>An optional method that returns the module object to use when
importing a module.  create_module() may also return <tt class="docutils literal"><span class="pre">None</span></tt>,
indicating that the default module creation should take place
instead.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.Loader.exec_module">
<tt class="descname">exec_module</tt><big>(</big><em>module</em><big>)</big><a class="headerlink" href="#importlib.abc.Loader.exec_module" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract method that executes the module in its own namespace
when a module is imported or reloaded.  The module should already
be initialized when exec_module() is called.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.Loader.load_module">
<tt class="descname">load_module</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.Loader.load_module" title="Permalink to this definition">¶</a></dt>
<dd><p>A legacy method for loading a module. If the module cannot be
loaded, <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> is raised, otherwise the loaded module is
returned.</p>
<p>If the requested module already exists in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a>, that
module should be used and reloaded.
Otherwise the loader should create a new module and insert it into
<a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a> before any loading begins, to prevent recursion
from the import. If the loader inserted a module and the load fails, it
must be removed by the loader from <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a>; modules already
in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a> before the loader began execution should be left
alone (see <a class="reference internal" href="#importlib.util.module_for_loader" title="importlib.util.module_for_loader"><tt class="xref py py-func docutils literal"><span class="pre">importlib.util.module_for_loader()</span></tt></a>).</p>
<p>The loader should set several attributes on the module.
(Note that some of these attributes can change when a module is
reloaded):</p>
<ul>
<li><dl class="first docutils">
<dt><a class="reference internal" href="../reference/import.html#__name__" title="__name__"><tt class="xref py py-attr docutils literal"><span class="pre">__name__</span></tt></a></dt>
<dd><p class="first last">The name of the module.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference internal" href="../reference/import.html#__file__" title="__file__"><tt class="xref py py-attr docutils literal"><span class="pre">__file__</span></tt></a></dt>
<dd><p class="first last">The path to where the module data is stored (not set for built-in
modules).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference internal" href="../reference/import.html#__cached__" title="__cached__"><tt class="xref py py-attr docutils literal"><span class="pre">__cached__</span></tt></a></dt>
<dd><p class="first last">The path to where a compiled version of the module is/should be
stored (not set when the attribute would be inappropriate).</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference internal" href="../reference/import.html#__path__" title="__path__"><tt class="xref py py-attr docutils literal"><span class="pre">__path__</span></tt></a></dt>
<dd><p class="first last">A list of strings specifying the search path within a
package. This attribute is not set on modules.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference internal" href="../reference/import.html#__package__" title="__package__"><tt class="xref py py-attr docutils literal"><span class="pre">__package__</span></tt></a></dt>
<dd><p class="first last">The parent package for the module/package. If the module is
top-level then it has a value of the empty string. The
<a class="reference internal" href="#importlib.util.module_for_loader" title="importlib.util.module_for_loader"><tt class="xref py py-func docutils literal"><span class="pre">importlib.util.module_for_loader()</span></tt></a> decorator can handle the
details for <a class="reference internal" href="../reference/import.html#__package__" title="__package__"><tt class="xref py py-attr docutils literal"><span class="pre">__package__</span></tt></a>.</p>
</dd>
</dl>
</li>
<li><dl class="first docutils">
<dt><a class="reference internal" href="../reference/import.html#__loader__" title="__loader__"><tt class="xref py py-attr docutils literal"><span class="pre">__loader__</span></tt></a></dt>
<dd><p class="first last">The loader used to load the module. The
<a class="reference internal" href="#importlib.util.module_for_loader" title="importlib.util.module_for_loader"><tt class="xref py py-func docutils literal"><span class="pre">importlib.util.module_for_loader()</span></tt></a> decorator can handle the
details for <a class="reference internal" href="../reference/import.html#__package__" title="__package__"><tt class="xref py py-attr docutils literal"><span class="pre">__package__</span></tt></a>.</p>
</dd>
</dl>
</li>
</ul>
<p>When <a class="reference internal" href="#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><tt class="xref py py-meth docutils literal"><span class="pre">exec_module()</span></tt></a> is available then backwards-compatible
functionality is provided.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Raise <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> when called instead of
<a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>. Functionality provided when
<a class="reference internal" href="#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><tt class="xref py py-meth docutils literal"><span class="pre">exec_module()</span></tt></a> is available.</p>
</div>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>The recommended API for loading a module is <a class="reference internal" href="#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><tt class="xref py py-meth docutils literal"><span class="pre">exec_module()</span></tt></a>
(and optionally <a class="reference internal" href="#importlib.abc.Loader.create_module" title="importlib.abc.Loader.create_module"><tt class="xref py py-meth docutils literal"><span class="pre">create_module()</span></tt></a>).  Loaders should implement
it instead of load_module().  The import machinery takes care of
all the other responsibilities of load_module() when exec_module()
is implemented.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.Loader.module_repr">
<tt class="descname">module_repr</tt><big>(</big><em>module</em><big>)</big><a class="headerlink" href="#importlib.abc.Loader.module_repr" title="Permalink to this definition">¶</a></dt>
<dd><p>A legacy method which when implemented calculates and returns the
given module&#8217;s repr, as a string. The module type&#8217;s default repr() will
use the result of this method as appropriate.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Made optional instead of an abstractmethod.</p>
</div>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>The import machinery now takes care of this automatically.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.abc.ResourceLoader">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">ResourceLoader</tt><a class="headerlink" href="#importlib.abc.ResourceLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class for a <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a> which implements the optional
<span class="target" id="index-10"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a> protocol for loading arbitrary resources from the storage
back-end.</p>
<dl class="method">
<dt id="importlib.abc.ResourceLoader.get_data">
<tt class="descname">get_data</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#importlib.abc.ResourceLoader.get_data" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract method to return the bytes for the data located at <em>path</em>.
Loaders that have a file-like storage back-end
that allows storing arbitrary data
can implement this abstract method to give direct access
to the data stored. <a class="reference internal" href="exceptions.html#OSError" title="OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> is to be raised if the <em>path</em> cannot
be found. The <em>path</em> is expected to be constructed using a module&#8217;s
<a class="reference internal" href="../reference/import.html#__file__" title="__file__"><tt class="xref py py-attr docutils literal"><span class="pre">__file__</span></tt></a> attribute or an item from a package&#8217;s <a class="reference internal" href="../reference/import.html#__path__" title="__path__"><tt class="xref py py-attr docutils literal"><span class="pre">__path__</span></tt></a>.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Raises <a class="reference internal" href="exceptions.html#OSError" title="OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> instead of <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.abc.InspectLoader">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">InspectLoader</tt><a class="headerlink" href="#importlib.abc.InspectLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class for a <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a> which implements the optional
<span class="target" id="index-11"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a> protocol for loaders that inspect modules.</p>
<dl class="method">
<dt id="importlib.abc.InspectLoader.get_code">
<tt class="descname">get_code</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.InspectLoader.get_code" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the code object for a module, or <tt class="docutils literal"><span class="pre">None</span></tt> if the module does not
have a code object (as would be the case, for example, for a built-in
module).  Raise an <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> if loader cannot find the
requested module.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">While the method has a default implementation, it is suggested that
it be overridden if possible for performance.</p>
</div>
<div class="versionchanged" id="index-12">
<p><span class="versionmodified">Changed in version 3.4: </span>No longer abstract and a concrete implementation is provided.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.InspectLoader.get_source">
<tt class="descname">get_source</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.InspectLoader.get_source" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract method to return the source of a module. It is returned as
a text string using <a class="reference internal" href="../glossary.html#term-universal-newlines"><em class="xref std std-term">universal newlines</em></a>, translating all
recognized line separators into <tt class="docutils literal"><span class="pre">'\n'</span></tt> characters.  Returns <tt class="docutils literal"><span class="pre">None</span></tt>
if no source is available (e.g. a built-in module). Raises
<a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> if the loader cannot find the module specified.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Raises <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> instead of <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.InspectLoader.is_package">
<tt class="descname">is_package</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.InspectLoader.is_package" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract method to return a true value if the module is a package, a
false value otherwise. <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> is raised if the
<a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a> cannot find the module.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Raises <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> instead of <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.InspectLoader.source_to_code">
<tt class="descname">source_to_code</tt><big>(</big><em>data</em>, <em>path='&lt;string&gt;'</em><big>)</big><a class="headerlink" href="#importlib.abc.InspectLoader.source_to_code" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a code object from Python source.</p>
<p>The <em>data</em> argument can be whatever the <a class="reference internal" href="functions.html#compile" title="compile"><tt class="xref py py-func docutils literal"><span class="pre">compile()</span></tt></a> function
supports (i.e. string or bytes). The <em>path</em> argument should be
the &#8220;path&#8221; to where the source code originated from, which can be an
abstract concept (e.g. location in a zip file).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.InspectLoader.exec_module">
<tt class="descname">exec_module</tt><big>(</big><em>module</em><big>)</big><a class="headerlink" href="#importlib.abc.InspectLoader.exec_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Implementation of <a class="reference internal" href="#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><tt class="xref py py-meth docutils literal"><span class="pre">Loader.exec_module()</span></tt></a>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.InspectLoader.load_module">
<tt class="descname">load_module</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.InspectLoader.load_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Implementation of <a class="reference internal" href="#importlib.abc.Loader.load_module" title="importlib.abc.Loader.load_module"><tt class="xref py py-meth docutils literal"><span class="pre">Loader.load_module()</span></tt></a>.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>use <a class="reference internal" href="#importlib.abc.InspectLoader.exec_module" title="importlib.abc.InspectLoader.exec_module"><tt class="xref py py-meth docutils literal"><span class="pre">exec_module()</span></tt></a> instead.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.abc.ExecutionLoader">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">ExecutionLoader</tt><a class="headerlink" href="#importlib.abc.ExecutionLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class which inherits from <a class="reference internal" href="#importlib.abc.InspectLoader" title="importlib.abc.InspectLoader"><tt class="xref py py-class docutils literal"><span class="pre">InspectLoader</span></tt></a> that,
when implemented, helps a module to be executed as a script. The ABC
represents an optional <span class="target" id="index-13"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0302"><strong>PEP 302</strong></a> protocol.</p>
<dl class="method">
<dt id="importlib.abc.ExecutionLoader.get_filename">
<tt class="descname">get_filename</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.ExecutionLoader.get_filename" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract method that is to return the value of <a class="reference internal" href="../reference/import.html#__file__" title="__file__"><tt class="xref py py-attr docutils literal"><span class="pre">__file__</span></tt></a> for
the specified module. If no path is available, <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> is
raised.</p>
<p>If source code is available, then the method should return the path to
the source file, regardless of whether a bytecode was used to load the
module.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Raises <a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> instead of <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>.</p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.abc.FileLoader">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">FileLoader</tt><big>(</big><em>fullname</em>, <em>path</em><big>)</big><a class="headerlink" href="#importlib.abc.FileLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class which inherits from <a class="reference internal" href="#importlib.abc.ResourceLoader" title="importlib.abc.ResourceLoader"><tt class="xref py py-class docutils literal"><span class="pre">ResourceLoader</span></tt></a> and
<a class="reference internal" href="#importlib.abc.ExecutionLoader" title="importlib.abc.ExecutionLoader"><tt class="xref py py-class docutils literal"><span class="pre">ExecutionLoader</span></tt></a>, providing concrete implementations of
<a class="reference internal" href="#importlib.abc.ResourceLoader.get_data" title="importlib.abc.ResourceLoader.get_data"><tt class="xref py py-meth docutils literal"><span class="pre">ResourceLoader.get_data()</span></tt></a> and <a class="reference internal" href="#importlib.abc.ExecutionLoader.get_filename" title="importlib.abc.ExecutionLoader.get_filename"><tt class="xref py py-meth docutils literal"><span class="pre">ExecutionLoader.get_filename()</span></tt></a>.</p>
<p>The <em>fullname</em> argument is a fully resolved name of the module the loader is
to handle. The <em>path</em> argument is the path to the file for the module.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<dl class="attribute">
<dt id="importlib.abc.FileLoader.name">
<tt class="descname">name</tt><a class="headerlink" href="#importlib.abc.FileLoader.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the module the loader can handle.</p>
</dd></dl>

<dl class="attribute">
<dt id="importlib.abc.FileLoader.path">
<tt class="descname">path</tt><a class="headerlink" href="#importlib.abc.FileLoader.path" title="Permalink to this definition">¶</a></dt>
<dd><p>Path to the file of the module.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.FileLoader.load_module">
<tt class="descname">load_module</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.FileLoader.load_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Calls super&#8217;s <tt class="docutils literal"><span class="pre">load_module()</span></tt>.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>Use <a class="reference internal" href="#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><tt class="xref py py-meth docutils literal"><span class="pre">Loader.exec_module()</span></tt></a> instead.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.FileLoader.get_filename">
<tt class="descname">get_filename</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.FileLoader.get_filename" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <a class="reference internal" href="#importlib.abc.FileLoader.path" title="importlib.abc.FileLoader.path"><tt class="xref py py-attr docutils literal"><span class="pre">path</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.FileLoader.get_data">
<tt class="descname">get_data</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#importlib.abc.FileLoader.get_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Reads <em>path</em> as a binary file and returns the bytes from it.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.abc.SourceLoader">
<em class="property">class </em><tt class="descclassname">importlib.abc.</tt><tt class="descname">SourceLoader</tt><a class="headerlink" href="#importlib.abc.SourceLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>An abstract base class for implementing source (and optionally bytecode)
file loading. The class inherits from both <a class="reference internal" href="#importlib.abc.ResourceLoader" title="importlib.abc.ResourceLoader"><tt class="xref py py-class docutils literal"><span class="pre">ResourceLoader</span></tt></a> and
<a class="reference internal" href="#importlib.abc.ExecutionLoader" title="importlib.abc.ExecutionLoader"><tt class="xref py py-class docutils literal"><span class="pre">ExecutionLoader</span></tt></a>, requiring the implementation of:</p>
<ul>
<li><p class="first"><a class="reference internal" href="#importlib.abc.ResourceLoader.get_data" title="importlib.abc.ResourceLoader.get_data"><tt class="xref py py-meth docutils literal"><span class="pre">ResourceLoader.get_data()</span></tt></a></p>
</li>
<li><dl class="first docutils">
<dt><a class="reference internal" href="#importlib.abc.ExecutionLoader.get_filename" title="importlib.abc.ExecutionLoader.get_filename"><tt class="xref py py-meth docutils literal"><span class="pre">ExecutionLoader.get_filename()</span></tt></a></dt>
<dd><p class="first last">Should only return the path to the source file; sourceless
loading is not supported.</p>
</dd>
</dl>
</li>
</ul>
<p>The abstract methods defined by this class are to add optional bytecode
file support. Not implementing these optional methods (or causing them to
raise <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>) causes the loader to
only work with source code. Implementing the methods allows the loader to
work with source <em>and</em> bytecode files; it does not allow for <em>sourceless</em>
loading where only bytecode is provided.  Bytecode files are an
optimization to speed up loading by removing the parsing step of Python&#8217;s
compiler, and so no bytecode-specific API is exposed.</p>
<dl class="method">
<dt id="importlib.abc.SourceLoader.path_stats">
<tt class="descname">path_stats</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#importlib.abc.SourceLoader.path_stats" title="Permalink to this definition">¶</a></dt>
<dd><p>Optional abstract method which returns a <a class="reference internal" href="stdtypes.html#dict" title="dict"><tt class="xref py py-class docutils literal"><span class="pre">dict</span></tt></a> containing
metadata about the specifed path.  Supported dictionary keys are:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">'mtime'</span></tt> (mandatory): an integer or floating-point number
representing the modification time of the source code;</li>
<li><tt class="docutils literal"><span class="pre">'size'</span></tt> (optional): the size in bytes of the source code.</li>
</ul>
<p>Any other keys in the dictionary are ignored, to allow for future
extensions. If the path cannot be handled, <a class="reference internal" href="exceptions.html#OSError" title="OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> is raised.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Raise <a class="reference internal" href="exceptions.html#OSError" title="OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> instead of <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.SourceLoader.path_mtime">
<tt class="descname">path_mtime</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#importlib.abc.SourceLoader.path_mtime" title="Permalink to this definition">¶</a></dt>
<dd><p>Optional abstract method which returns the modification time for the
specified path.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.3: </span>This method is deprecated in favour of <a class="reference internal" href="#importlib.abc.SourceLoader.path_stats" title="importlib.abc.SourceLoader.path_stats"><tt class="xref py py-meth docutils literal"><span class="pre">path_stats()</span></tt></a>.  You don&#8217;t
have to implement it, but it is still available for compatibility
purposes. Raise <a class="reference internal" href="exceptions.html#OSError" title="OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> if the path cannot be handled.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Raise <a class="reference internal" href="exceptions.html#OSError" title="OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> instead of <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.SourceLoader.set_data">
<tt class="descname">set_data</tt><big>(</big><em>path</em>, <em>data</em><big>)</big><a class="headerlink" href="#importlib.abc.SourceLoader.set_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Optional abstract method which writes the specified bytes to a file
path. Any intermediate directories which do not exist are to be created
automatically.</p>
<p>When writing to the path fails because the path is read-only
(<a class="reference internal" href="errno.html#errno.EACCES" title="errno.EACCES"><tt class="xref py py-attr docutils literal"><span class="pre">errno.EACCES</span></tt></a>/<a class="reference internal" href="exceptions.html#PermissionError" title="PermissionError"><tt class="xref py py-exc docutils literal"><span class="pre">PermissionError</span></tt></a>), do not propagate the
exception.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>No longer raises <a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a> when called.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.SourceLoader.get_code">
<tt class="descname">get_code</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.SourceLoader.get_code" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete implementation of <a class="reference internal" href="#importlib.abc.InspectLoader.get_code" title="importlib.abc.InspectLoader.get_code"><tt class="xref py py-meth docutils literal"><span class="pre">InspectLoader.get_code()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.SourceLoader.exec_module">
<tt class="descname">exec_module</tt><big>(</big><em>module</em><big>)</big><a class="headerlink" href="#importlib.abc.SourceLoader.exec_module" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div>Concrete implementation of <a class="reference internal" href="#importlib.abc.Loader.exec_module" title="importlib.abc.Loader.exec_module"><tt class="xref py py-meth docutils literal"><span class="pre">Loader.exec_module()</span></tt></a>.</div></blockquote>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.SourceLoader.load_module">
<tt class="descname">load_module</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.SourceLoader.load_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete implementation of <a class="reference internal" href="#importlib.abc.Loader.load_module" title="importlib.abc.Loader.load_module"><tt class="xref py py-meth docutils literal"><span class="pre">Loader.load_module()</span></tt></a>.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>Use <a class="reference internal" href="#importlib.abc.SourceLoader.exec_module" title="importlib.abc.SourceLoader.exec_module"><tt class="xref py py-meth docutils literal"><span class="pre">exec_module()</span></tt></a> instead.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.SourceLoader.get_source">
<tt class="descname">get_source</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.SourceLoader.get_source" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete implementation of <a class="reference internal" href="#importlib.abc.InspectLoader.get_source" title="importlib.abc.InspectLoader.get_source"><tt class="xref py py-meth docutils literal"><span class="pre">InspectLoader.get_source()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.abc.SourceLoader.is_package">
<tt class="descname">is_package</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.abc.SourceLoader.is_package" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete implementation of <a class="reference internal" href="#importlib.abc.InspectLoader.is_package" title="importlib.abc.InspectLoader.is_package"><tt class="xref py py-meth docutils literal"><span class="pre">InspectLoader.is_package()</span></tt></a>. A module
is determined to be a package if its file path (as provided by
<a class="reference internal" href="#importlib.abc.ExecutionLoader.get_filename" title="importlib.abc.ExecutionLoader.get_filename"><tt class="xref py py-meth docutils literal"><span class="pre">ExecutionLoader.get_filename()</span></tt></a>) is a file named
<tt class="docutils literal"><span class="pre">__init__</span></tt> when the file extension is removed <strong>and</strong> the module name
itself does not end in <tt class="docutils literal"><span class="pre">__init__</span></tt>.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-importlib.machinery">
<span id="importlib-machinery-importers-and-path-hooks"></span><h2>31.5.4. <a class="reference internal" href="#module-importlib.machinery" title="importlib.machinery: Importers and path hooks"><tt class="xref py py-mod docutils literal"><span class="pre">importlib.machinery</span></tt></a> &#8211; Importers and path hooks<a class="headerlink" href="#module-importlib.machinery" title="Permalink to this headline">¶</a></h2>
<p>This module contains the various objects that help <a class="reference internal" href="../reference/simple_stmts.html#import"><tt class="xref std std-keyword docutils literal"><span class="pre">import</span></tt></a>
find and load modules.</p>
<dl class="attribute">
<dt id="importlib.machinery.SOURCE_SUFFIXES">
<tt class="descclassname">importlib.machinery.</tt><tt class="descname">SOURCE_SUFFIXES</tt><a class="headerlink" href="#importlib.machinery.SOURCE_SUFFIXES" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of strings representing the recognized file suffixes for source
modules.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="importlib.machinery.DEBUG_BYTECODE_SUFFIXES">
<tt class="descclassname">importlib.machinery.</tt><tt class="descname">DEBUG_BYTECODE_SUFFIXES</tt><a class="headerlink" href="#importlib.machinery.DEBUG_BYTECODE_SUFFIXES" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of strings representing the file suffixes for non-optimized bytecode
modules.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES">
<tt class="descclassname">importlib.machinery.</tt><tt class="descname">OPTIMIZED_BYTECODE_SUFFIXES</tt><a class="headerlink" href="#importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of strings representing the file suffixes for optimized bytecode
modules.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="importlib.machinery.BYTECODE_SUFFIXES">
<tt class="descclassname">importlib.machinery.</tt><tt class="descname">BYTECODE_SUFFIXES</tt><a class="headerlink" href="#importlib.machinery.BYTECODE_SUFFIXES" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of strings representing the recognized file suffixes for bytecode
modules. Set to either <a class="reference internal" href="#importlib.machinery.DEBUG_BYTECODE_SUFFIXES" title="importlib.machinery.DEBUG_BYTECODE_SUFFIXES"><tt class="xref py py-attr docutils literal"><span class="pre">DEBUG_BYTECODE_SUFFIXES</span></tt></a> or
<a class="reference internal" href="#importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES" title="importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES"><tt class="xref py py-attr docutils literal"><span class="pre">OPTIMIZED_BYTECODE_SUFFIXES</span></tt></a> based on whether <tt class="docutils literal"><span class="pre">__debug__</span></tt> is true.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="attribute">
<dt id="importlib.machinery.EXTENSION_SUFFIXES">
<tt class="descclassname">importlib.machinery.</tt><tt class="descname">EXTENSION_SUFFIXES</tt><a class="headerlink" href="#importlib.machinery.EXTENSION_SUFFIXES" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of strings representing the recognized file suffixes for
extension modules.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.machinery.all_suffixes">
<tt class="descclassname">importlib.machinery.</tt><tt class="descname">all_suffixes</tt><big>(</big><big>)</big><a class="headerlink" href="#importlib.machinery.all_suffixes" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns a combined list of strings representing all file suffixes for
modules recognized by the standard import machinery. This is a
helper for code which simply needs to know if a filesystem path
potentially refers to a module without needing any details on the kind
of module (for example, <a class="reference internal" href="inspect.html#inspect.getmodulename" title="inspect.getmodulename"><tt class="xref py py-func docutils literal"><span class="pre">inspect.getmodulename()</span></tt></a>)</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="class">
<dt id="importlib.machinery.BuiltinImporter">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">BuiltinImporter</tt><a class="headerlink" href="#importlib.machinery.BuiltinImporter" title="Permalink to this definition">¶</a></dt>
<dd><p>An <a class="reference internal" href="../glossary.html#term-importer"><em class="xref std std-term">importer</em></a> for built-in modules. All known built-in modules are
listed in <a class="reference internal" href="sys.html#sys.builtin_module_names" title="sys.builtin_module_names"><tt class="xref py py-data docutils literal"><span class="pre">sys.builtin_module_names</span></tt></a>. This class implements the
<a class="reference internal" href="#importlib.abc.MetaPathFinder" title="importlib.abc.MetaPathFinder"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.MetaPathFinder</span></tt></a> and
<a class="reference internal" href="#importlib.abc.InspectLoader" title="importlib.abc.InspectLoader"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.InspectLoader</span></tt></a> ABCs.</p>
<p>Only class methods are defined by this class to alleviate the need for
instantiation.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Due to limitations in the extension module C-API, for now
BuiltinImporter does not implement <tt class="xref py py-meth docutils literal"><span class="pre">Loader.exec_module()</span></tt>.</p>
</div>
</dd></dl>

<dl class="class">
<dt id="importlib.machinery.FrozenImporter">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">FrozenImporter</tt><a class="headerlink" href="#importlib.machinery.FrozenImporter" title="Permalink to this definition">¶</a></dt>
<dd><p>An <a class="reference internal" href="../glossary.html#term-importer"><em class="xref std std-term">importer</em></a> for frozen modules. This class implements the
<a class="reference internal" href="#importlib.abc.MetaPathFinder" title="importlib.abc.MetaPathFinder"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.MetaPathFinder</span></tt></a> and
<a class="reference internal" href="#importlib.abc.InspectLoader" title="importlib.abc.InspectLoader"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.InspectLoader</span></tt></a> ABCs.</p>
<p>Only class methods are defined by this class to alleviate the need for
instantiation.</p>
</dd></dl>

<dl class="class">
<dt id="importlib.machinery.WindowsRegistryFinder">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">WindowsRegistryFinder</tt><a class="headerlink" href="#importlib.machinery.WindowsRegistryFinder" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../glossary.html#term-finder"><em class="xref std std-term">Finder</em></a> for modules declared in the Windows registry.  This class
implements the <a class="reference internal" href="#importlib.abc.Finder" title="importlib.abc.Finder"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.Finder</span></tt></a> ABC.</p>
<p>Only class methods are defined by this class to alleviate the need for
instantiation.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="class">
<dt id="importlib.machinery.PathFinder">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">PathFinder</tt><a class="headerlink" href="#importlib.machinery.PathFinder" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="../glossary.html#term-finder"><em class="xref std std-term">Finder</em></a> for <a class="reference internal" href="sys.html#sys.path" title="sys.path"><tt class="xref py py-data docutils literal"><span class="pre">sys.path</span></tt></a> and package <tt class="docutils literal"><span class="pre">__path__</span></tt> attributes.
This class implements the <a class="reference internal" href="#importlib.abc.MetaPathFinder" title="importlib.abc.MetaPathFinder"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.MetaPathFinder</span></tt></a> ABC.</p>
<p>Only class methods are defined by this class to alleviate the need for
instantiation.</p>
<dl class="classmethod">
<dt id="importlib.machinery.PathFinder.find_spec">
<em class="property">classmethod </em><tt class="descname">find_spec</tt><big>(</big><em>fullname</em>, <em>path=None</em>, <em>target=None</em><big>)</big><a class="headerlink" href="#importlib.machinery.PathFinder.find_spec" title="Permalink to this definition">¶</a></dt>
<dd><p>Class method that attempts to find a <a class="reference internal" href="../glossary.html#term-module-spec"><em class="xref std std-term">spec</em></a>
for the module specified by <em>fullname</em> on <a class="reference internal" href="sys.html#sys.path" title="sys.path"><tt class="xref py py-data docutils literal"><span class="pre">sys.path</span></tt></a> or, if
defined, on <em>path</em>. For each path entry that is searched,
<a class="reference internal" href="sys.html#sys.path_importer_cache" title="sys.path_importer_cache"><tt class="xref py py-data docutils literal"><span class="pre">sys.path_importer_cache</span></tt></a> is checked. If a non-false object
is found then it is used as the <a class="reference internal" href="../glossary.html#term-path-entry-finder"><em class="xref std std-term">path entry finder</em></a> to look
for the module being searched for. If no entry is found in
<a class="reference internal" href="sys.html#sys.path_importer_cache" title="sys.path_importer_cache"><tt class="xref py py-data docutils literal"><span class="pre">sys.path_importer_cache</span></tt></a>, then <a class="reference internal" href="sys.html#sys.path_hooks" title="sys.path_hooks"><tt class="xref py py-data docutils literal"><span class="pre">sys.path_hooks</span></tt></a> is
searched for a finder for the path entry and, if found, is stored
in <a class="reference internal" href="sys.html#sys.path_importer_cache" title="sys.path_importer_cache"><tt class="xref py py-data docutils literal"><span class="pre">sys.path_importer_cache</span></tt></a> along with being queried about
the module. If no finder is ever found then <tt class="docutils literal"><span class="pre">None</span></tt> is both
stored in the cache and returned.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="classmethod">
<dt id="importlib.machinery.PathFinder.find_module">
<em class="property">classmethod </em><tt class="descname">find_module</tt><big>(</big><em>fullname</em>, <em>path=None</em><big>)</big><a class="headerlink" href="#importlib.machinery.PathFinder.find_module" title="Permalink to this definition">¶</a></dt>
<dd><p>A legacy wrapper around <a class="reference internal" href="#importlib.machinery.PathFinder.find_spec" title="importlib.machinery.PathFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a>.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>Use <a class="reference internal" href="#importlib.machinery.PathFinder.find_spec" title="importlib.machinery.PathFinder.find_spec"><tt class="xref py py-meth docutils literal"><span class="pre">find_spec()</span></tt></a> instead.</p>
</div>
</dd></dl>

<dl class="classmethod">
<dt id="importlib.machinery.PathFinder.invalidate_caches">
<em class="property">classmethod </em><tt class="descname">invalidate_caches</tt><big>(</big><big>)</big><a class="headerlink" href="#importlib.machinery.PathFinder.invalidate_caches" title="Permalink to this definition">¶</a></dt>
<dd><p>Calls <a class="reference internal" href="#importlib.abc.PathEntryFinder.invalidate_caches" title="importlib.abc.PathEntryFinder.invalidate_caches"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.PathEntryFinder.invalidate_caches()</span></tt></a> on all
finders stored in <a class="reference internal" href="sys.html#sys.path_importer_cache" title="sys.path_importer_cache"><tt class="xref py py-attr docutils literal"><span class="pre">sys.path_importer_cache</span></tt></a>.</p>
</dd></dl>

<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Calls objects in <a class="reference internal" href="sys.html#sys.path_hooks" title="sys.path_hooks"><tt class="xref py py-data docutils literal"><span class="pre">sys.path_hooks</span></tt></a> with the current working
directory for <tt class="docutils literal"><span class="pre">''</span></tt> (i.e. the empty string).</p>
</div>
</dd></dl>

<dl class="class">
<dt id="importlib.machinery.FileFinder">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">FileFinder</tt><big>(</big><em>path</em>, <em>*loader_details</em><big>)</big><a class="headerlink" href="#importlib.machinery.FileFinder" title="Permalink to this definition">¶</a></dt>
<dd><p>A concrete implementation of <a class="reference internal" href="#importlib.abc.PathEntryFinder" title="importlib.abc.PathEntryFinder"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.PathEntryFinder</span></tt></a> which
caches results from the file system.</p>
<p>The <em>path</em> argument is the directory for which the finder is in charge of
searching.</p>
<p>The <em>loader_details</em> argument is a variable number of 2-item tuples each
containing a loader and a sequence of file suffixes the loader recognizes.
The loaders are expected to be callables which accept two arguments of
the module&#8217;s name and the path to the file found.</p>
<p>The finder will cache the directory contents as necessary, making stat calls
for each module search to verify the cache is not outdated. Because cache
staleness relies upon the granularity of the operating system&#8217;s state
information of the file system, there is a potential race condition of
searching for a module, creating a new file, and then searching for the
module the new file represents. If the operations happen fast enough to fit
within the granularity of stat calls, then the module search will fail. To
prevent this from happening, when you create a module dynamically, make sure
to call <a class="reference internal" href="#importlib.invalidate_caches" title="importlib.invalidate_caches"><tt class="xref py py-func docutils literal"><span class="pre">importlib.invalidate_caches()</span></tt></a>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<dl class="attribute">
<dt id="importlib.machinery.FileFinder.path">
<tt class="descname">path</tt><a class="headerlink" href="#importlib.machinery.FileFinder.path" title="Permalink to this definition">¶</a></dt>
<dd><p>The path the finder will search in.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.FileFinder.find_spec">
<tt class="descname">find_spec</tt><big>(</big><em>fullname</em>, <em>target=None</em><big>)</big><a class="headerlink" href="#importlib.machinery.FileFinder.find_spec" title="Permalink to this definition">¶</a></dt>
<dd><p>Attempt to find the spec to handle <em>fullname</em> within <a class="reference internal" href="#importlib.machinery.FileFinder.path" title="importlib.machinery.FileFinder.path"><tt class="xref py py-attr docutils literal"><span class="pre">path</span></tt></a>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.FileFinder.find_loader">
<tt class="descname">find_loader</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.FileFinder.find_loader" title="Permalink to this definition">¶</a></dt>
<dd><p>Attempt to find the loader to handle <em>fullname</em> within <a class="reference internal" href="#importlib.machinery.FileFinder.path" title="importlib.machinery.FileFinder.path"><tt class="xref py py-attr docutils literal"><span class="pre">path</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.FileFinder.invalidate_caches">
<tt class="descname">invalidate_caches</tt><big>(</big><big>)</big><a class="headerlink" href="#importlib.machinery.FileFinder.invalidate_caches" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear out the internal cache.</p>
</dd></dl>

<dl class="classmethod">
<dt id="importlib.machinery.FileFinder.path_hook">
<em class="property">classmethod </em><tt class="descname">path_hook</tt><big>(</big><em>*loader_details</em><big>)</big><a class="headerlink" href="#importlib.machinery.FileFinder.path_hook" title="Permalink to this definition">¶</a></dt>
<dd><p>A class method which returns a closure for use on <a class="reference internal" href="sys.html#sys.path_hooks" title="sys.path_hooks"><tt class="xref py py-attr docutils literal"><span class="pre">sys.path_hooks</span></tt></a>.
An instance of <a class="reference internal" href="#importlib.machinery.FileFinder" title="importlib.machinery.FileFinder"><tt class="xref py py-class docutils literal"><span class="pre">FileFinder</span></tt></a> is returned by the closure using the
path argument given to the closure directly and <em>loader_details</em>
indirectly.</p>
<p>If the argument to the closure is not an existing directory,
<a class="reference internal" href="exceptions.html#ImportError" title="ImportError"><tt class="xref py py-exc docutils literal"><span class="pre">ImportError</span></tt></a> is raised.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.machinery.SourceFileLoader">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">SourceFileLoader</tt><big>(</big><em>fullname</em>, <em>path</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourceFileLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>A concrete implementation of <a class="reference internal" href="#importlib.abc.SourceLoader" title="importlib.abc.SourceLoader"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.SourceLoader</span></tt></a> by
subclassing <a class="reference internal" href="#importlib.abc.FileLoader" title="importlib.abc.FileLoader"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.FileLoader</span></tt></a> and providing some concrete
implementations of other methods.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<dl class="attribute">
<dt id="importlib.machinery.SourceFileLoader.name">
<tt class="descname">name</tt><a class="headerlink" href="#importlib.machinery.SourceFileLoader.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the module that this loader will handle.</p>
</dd></dl>

<dl class="attribute">
<dt id="importlib.machinery.SourceFileLoader.path">
<tt class="descname">path</tt><a class="headerlink" href="#importlib.machinery.SourceFileLoader.path" title="Permalink to this definition">¶</a></dt>
<dd><p>The path to the source file.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.SourceFileLoader.is_package">
<tt class="descname">is_package</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourceFileLoader.is_package" title="Permalink to this definition">¶</a></dt>
<dd><p>Return true if <a class="reference internal" href="#importlib.machinery.SourceFileLoader.path" title="importlib.machinery.SourceFileLoader.path"><tt class="xref py py-attr docutils literal"><span class="pre">path</span></tt></a> appears to be for a package.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.SourceFileLoader.path_stats">
<tt class="descname">path_stats</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourceFileLoader.path_stats" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete implementation of <a class="reference internal" href="#importlib.abc.SourceLoader.path_stats" title="importlib.abc.SourceLoader.path_stats"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.SourceLoader.path_stats()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.SourceFileLoader.set_data">
<tt class="descname">set_data</tt><big>(</big><em>path</em>, <em>data</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourceFileLoader.set_data" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete implementation of <a class="reference internal" href="#importlib.abc.SourceLoader.set_data" title="importlib.abc.SourceLoader.set_data"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.SourceLoader.set_data()</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.SourceFileLoader.load_module">
<tt class="descname">load_module</tt><big>(</big><em>name=None</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourceFileLoader.load_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Concrete implementation of <a class="reference internal" href="#importlib.abc.Loader.load_module" title="importlib.abc.Loader.load_module"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.Loader.load_module()</span></tt></a> where
specifying the name of the module to load is optional.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.machinery.SourcelessFileLoader">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">SourcelessFileLoader</tt><big>(</big><em>fullname</em>, <em>path</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourcelessFileLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>A concrete implementation of <a class="reference internal" href="#importlib.abc.FileLoader" title="importlib.abc.FileLoader"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.FileLoader</span></tt></a> which can
import bytecode files (i.e. no source code files exist).</p>
<p>Please note that direct use of bytecode files (and thus not source code
files) inhibits your modules from being usable by all Python
implementations or new versions of Python which change the bytecode
format.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<dl class="attribute">
<dt id="importlib.machinery.SourcelessFileLoader.name">
<tt class="descname">name</tt><a class="headerlink" href="#importlib.machinery.SourcelessFileLoader.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the module the loader will handle.</p>
</dd></dl>

<dl class="attribute">
<dt id="importlib.machinery.SourcelessFileLoader.path">
<tt class="descname">path</tt><a class="headerlink" href="#importlib.machinery.SourcelessFileLoader.path" title="Permalink to this definition">¶</a></dt>
<dd><p>The path to the bytecode file.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.SourcelessFileLoader.is_package">
<tt class="descname">is_package</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourcelessFileLoader.is_package" title="Permalink to this definition">¶</a></dt>
<dd><p>Determines if the module is a package based on <a class="reference internal" href="#importlib.machinery.SourcelessFileLoader.path" title="importlib.machinery.SourcelessFileLoader.path"><tt class="xref py py-attr docutils literal"><span class="pre">path</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.SourcelessFileLoader.get_code">
<tt class="descname">get_code</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourcelessFileLoader.get_code" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the code object for <a class="reference internal" href="#importlib.machinery.SourcelessFileLoader.name" title="importlib.machinery.SourcelessFileLoader.name"><tt class="xref py py-attr docutils literal"><span class="pre">name</span></tt></a> created from <a class="reference internal" href="#importlib.machinery.SourcelessFileLoader.path" title="importlib.machinery.SourcelessFileLoader.path"><tt class="xref py py-attr docutils literal"><span class="pre">path</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.SourcelessFileLoader.get_source">
<tt class="descname">get_source</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourcelessFileLoader.get_source" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <tt class="docutils literal"><span class="pre">None</span></tt> as bytecode files have no source when this loader is
used.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.SourcelessFileLoader.load_module">
<tt class="descname">load_module</tt><big>(</big><em>name=None</em><big>)</big><a class="headerlink" href="#importlib.machinery.SourcelessFileLoader.load_module" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Concrete implementation of <a class="reference internal" href="#importlib.abc.Loader.load_module" title="importlib.abc.Loader.load_module"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.Loader.load_module()</span></tt></a> where
specifying the name of the module to load is optional.</p>
</dd></dl>

<dl class="class">
<dt id="importlib.machinery.ExtensionFileLoader">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">ExtensionFileLoader</tt><big>(</big><em>fullname</em>, <em>path</em><big>)</big><a class="headerlink" href="#importlib.machinery.ExtensionFileLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>A concrete implementation of <a class="reference internal" href="#importlib.abc.ExecutionLoader" title="importlib.abc.ExecutionLoader"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.ExecutionLoader</span></tt></a> for
extension modules.</p>
<p>The <em>fullname</em> argument specifies the name of the module the loader is to
support. The <em>path</em> argument is the path to the extension module&#8217;s file.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
<dl class="attribute">
<dt id="importlib.machinery.ExtensionFileLoader.name">
<tt class="descname">name</tt><a class="headerlink" href="#importlib.machinery.ExtensionFileLoader.name" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of the module the loader supports.</p>
</dd></dl>

<dl class="attribute">
<dt id="importlib.machinery.ExtensionFileLoader.path">
<tt class="descname">path</tt><a class="headerlink" href="#importlib.machinery.ExtensionFileLoader.path" title="Permalink to this definition">¶</a></dt>
<dd><p>Path to the extension module.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.ExtensionFileLoader.load_module">
<tt class="descname">load_module</tt><big>(</big><em>name=None</em><big>)</big><a class="headerlink" href="#importlib.machinery.ExtensionFileLoader.load_module" title="Permalink to this definition">¶</a></dt>
<dd><p>Loads the extension module if and only if <em>fullname</em> is the same as
<a class="reference internal" href="#importlib.machinery.ExtensionFileLoader.name" title="importlib.machinery.ExtensionFileLoader.name"><tt class="xref py py-attr docutils literal"><span class="pre">name</span></tt></a> or is <tt class="docutils literal"><span class="pre">None</span></tt>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Due to limitations in the extension module C-API, for now
ExtensionFileLoader does not implement <tt class="xref py py-meth docutils literal"><span class="pre">Loader.exec_module()</span></tt>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.ExtensionFileLoader.is_package">
<tt class="descname">is_package</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.ExtensionFileLoader.is_package" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <tt class="docutils literal"><span class="pre">True</span></tt> if the file path points to a package&#8217;s <tt class="docutils literal"><span class="pre">__init__</span></tt>
module based on <a class="reference internal" href="#importlib.machinery.EXTENSION_SUFFIXES" title="importlib.machinery.EXTENSION_SUFFIXES"><tt class="xref py py-attr docutils literal"><span class="pre">EXTENSION_SUFFIXES</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.ExtensionFileLoader.get_code">
<tt class="descname">get_code</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.ExtensionFileLoader.get_code" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <tt class="docutils literal"><span class="pre">None</span></tt> as extension modules lack a code object.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.ExtensionFileLoader.get_source">
<tt class="descname">get_source</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.ExtensionFileLoader.get_source" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <tt class="docutils literal"><span class="pre">None</span></tt> as extension modules do not have source code.</p>
</dd></dl>

<dl class="method">
<dt id="importlib.machinery.ExtensionFileLoader.get_filename">
<tt class="descname">get_filename</tt><big>(</big><em>fullname</em><big>)</big><a class="headerlink" href="#importlib.machinery.ExtensionFileLoader.get_filename" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns <a class="reference internal" href="#importlib.machinery.ExtensionFileLoader.path" title="importlib.machinery.ExtensionFileLoader.path"><tt class="xref py py-attr docutils literal"><span class="pre">path</span></tt></a>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="importlib.machinery.ModuleSpec">
<em class="property">class </em><tt class="descclassname">importlib.machinery.</tt><tt class="descname">ModuleSpec</tt><big>(</big><em>name</em>, <em>loader</em>, <em>*</em>, <em>origin=None</em>, <em>loader_state=None</em>, <em>is_package=None</em><big>)</big><a class="headerlink" href="#importlib.machinery.ModuleSpec" title="Permalink to this definition">¶</a></dt>
<dd><p>A specification for a module&#8217;s import-system-related state.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
<dl class="attribute">
<dt id="importlib.machinery.ModuleSpec.name">
<tt class="descname">name</tt><a class="headerlink" href="#importlib.machinery.ModuleSpec.name" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>(<tt class="docutils literal"><span class="pre">__name__</span></tt>)</p>
<p>A string for the fully-qualified name of the module.</p>
<dl class="attribute">
<dt id="importlib.machinery.ModuleSpec.loader">
<tt class="descname">loader</tt><a class="headerlink" href="#importlib.machinery.ModuleSpec.loader" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>(<tt class="docutils literal"><span class="pre">__loader__</span></tt>)</p>
<p>The loader to use for loading.  For namespace packages this should be
set to None.</p>
<dl class="attribute">
<dt id="importlib.machinery.ModuleSpec.origin">
<tt class="descname">origin</tt><a class="headerlink" href="#importlib.machinery.ModuleSpec.origin" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>(<tt class="docutils literal"><span class="pre">__file__</span></tt>)</p>
<p>Name of the place from which the module is loaded, e.g. &#8220;builtin&#8221; for
built-in modules and the filename for modules loaded from source.
Normally &#8220;origin&#8221; should be set, but it may be None (the default)
which indicates it is unspecified.</p>
<dl class="attribute">
<dt id="importlib.machinery.ModuleSpec.submodule_search_locations">
<tt class="descname">submodule_search_locations</tt><a class="headerlink" href="#importlib.machinery.ModuleSpec.submodule_search_locations" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>(<tt class="docutils literal"><span class="pre">__path__</span></tt>)</p>
<p>List of strings for where to find submodules, if a package (None
otherwise).</p>
<dl class="attribute">
<dt id="importlib.machinery.ModuleSpec.loader_state">
<tt class="descname">loader_state</tt><a class="headerlink" href="#importlib.machinery.ModuleSpec.loader_state" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Container of extra module-specific data for use during loading (or
None).</p>
<dl class="attribute">
<dt id="importlib.machinery.ModuleSpec.cached">
<tt class="descname">cached</tt><a class="headerlink" href="#importlib.machinery.ModuleSpec.cached" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>(<tt class="docutils literal"><span class="pre">__cached__</span></tt>)</p>
<p>String for where the compiled module should be stored (or None).</p>
<dl class="attribute">
<dt id="importlib.machinery.ModuleSpec.parent">
<tt class="descname">parent</tt><a class="headerlink" href="#importlib.machinery.ModuleSpec.parent" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>(<tt class="docutils literal"><span class="pre">__package__</span></tt>)</p>
<p>(Read-only) Fully-qualified name of the package to which the module
belongs as a submodule (or None).</p>
<dl class="attribute">
<dt id="importlib.machinery.ModuleSpec.has_location">
<tt class="descname">has_location</tt><a class="headerlink" href="#importlib.machinery.ModuleSpec.has_location" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>Boolean indicating whether or not the module&#8217;s &#8220;origin&#8221;
attribute refers to a loadable location.</p>
</dd></dl>

</div>
<div class="section" id="module-importlib.util">
<span id="importlib-util-utility-code-for-importers"></span><h2>31.5.5. <a class="reference internal" href="#module-importlib.util" title="importlib.util: Utility code for importers"><tt class="xref py py-mod docutils literal"><span class="pre">importlib.util</span></tt></a> &#8211; Utility code for importers<a class="headerlink" href="#module-importlib.util" title="Permalink to this headline">¶</a></h2>
<p>This module contains the various objects that help in the construction of
an <a class="reference internal" href="../glossary.html#term-importer"><em class="xref std std-term">importer</em></a>.</p>
<dl class="attribute">
<dt id="importlib.util.MAGIC_NUMBER">
<tt class="descclassname">importlib.util.</tt><tt class="descname">MAGIC_NUMBER</tt><a class="headerlink" href="#importlib.util.MAGIC_NUMBER" title="Permalink to this definition">¶</a></dt>
<dd><p>The bytes which represent the bytecode version number. If you need help with
loading/writing bytecode then consider <a class="reference internal" href="#importlib.abc.SourceLoader" title="importlib.abc.SourceLoader"><tt class="xref py py-class docutils literal"><span class="pre">importlib.abc.SourceLoader</span></tt></a>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.cache_from_source">
<tt class="descclassname">importlib.util.</tt><tt class="descname">cache_from_source</tt><big>(</big><em>path</em>, <em>debug_override=None</em><big>)</big><a class="headerlink" href="#importlib.util.cache_from_source" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <span class="target" id="index-14"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-3147"><strong>PEP 3147</strong></a> path to the byte-compiled file associated with the
source <em>path</em>.  For example, if <em>path</em> is <tt class="docutils literal"><span class="pre">/foo/bar/baz.py</span></tt> the return
value would be <tt class="docutils literal"><span class="pre">/foo/bar/__pycache__/baz.cpython-32.pyc</span></tt> for Python 3.2.
The <tt class="docutils literal"><span class="pre">cpython-32</span></tt> string comes from the current magic tag (see
<tt class="xref py py-func docutils literal"><span class="pre">get_tag()</span></tt>; if <tt class="xref py py-attr docutils literal"><span class="pre">sys.implementation.cache_tag</span></tt> is not defined then
<a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a> will be raised).  The returned path will end in
<tt class="docutils literal"><span class="pre">.pyc</span></tt> when <tt class="docutils literal"><span class="pre">__debug__</span></tt> is <tt class="docutils literal"><span class="pre">True</span></tt> or <tt class="docutils literal"><span class="pre">.pyo</span></tt> for an optimized Python
(i.e. <tt class="docutils literal"><span class="pre">__debug__</span></tt> is <tt class="docutils literal"><span class="pre">False</span></tt>).  By passing in <tt class="docutils literal"><span class="pre">True</span></tt> or <tt class="docutils literal"><span class="pre">False</span></tt> for
<em>debug_override</em> you can override the system&#8217;s value for <tt class="docutils literal"><span class="pre">__debug__</span></tt> for
extension selection.</p>
<p><em>path</em> need not exist.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.source_from_cache">
<tt class="descclassname">importlib.util.</tt><tt class="descname">source_from_cache</tt><big>(</big><em>path</em><big>)</big><a class="headerlink" href="#importlib.util.source_from_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>Given the <em>path</em> to a <span class="target" id="index-15"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-3147"><strong>PEP 3147</strong></a> file name, return the associated source code
file path.  For example, if <em>path</em> is
<tt class="docutils literal"><span class="pre">/foo/bar/__pycache__/baz.cpython-32.pyc</span></tt> the returned path would be
<tt class="docutils literal"><span class="pre">/foo/bar/baz.py</span></tt>.  <em>path</em> need not exist, however if it does not conform
to <span class="target" id="index-16"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-3147"><strong>PEP 3147</strong></a> format, a <tt class="docutils literal"><span class="pre">ValueError</span></tt> is raised. If
<tt class="xref py py-attr docutils literal"><span class="pre">sys.implementation.cache_tag</span></tt> is not defined,
<a class="reference internal" href="exceptions.html#NotImplementedError" title="NotImplementedError"><tt class="xref py py-exc docutils literal"><span class="pre">NotImplementedError</span></tt></a> is raised.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.decode_source">
<tt class="descclassname">importlib.util.</tt><tt class="descname">decode_source</tt><big>(</big><em>source_bytes</em><big>)</big><a class="headerlink" href="#importlib.util.decode_source" title="Permalink to this definition">¶</a></dt>
<dd><p>Decode the given bytes representing source code and return it as a string
with universal newlines (as required by
<a class="reference internal" href="#importlib.abc.InspectLoader.get_source" title="importlib.abc.InspectLoader.get_source"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.InspectLoader.get_source()</span></tt></a>).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.resolve_name">
<tt class="descclassname">importlib.util.</tt><tt class="descname">resolve_name</tt><big>(</big><em>name</em>, <em>package</em><big>)</big><a class="headerlink" href="#importlib.util.resolve_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Resolve a relative module name to an absolute one.</p>
<p>If  <strong>name</strong> has no leading dots, then <strong>name</strong> is simply returned. This
allows for usage such as
<tt class="docutils literal"><span class="pre">importlib.util.resolve_name('sys',</span> <span class="pre">__package__)</span></tt> without doing a
check to see if the <strong>package</strong> argument is needed.</p>
<p><a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> is raised if <strong>name</strong> is a relative module name but
package is a false value (e.g. <tt class="docutils literal"><span class="pre">None</span></tt> or the empty string).
<a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> is also raised a relative name would escape its containing
package (e.g. requesting <tt class="docutils literal"><span class="pre">..bacon</span></tt> from within the <tt class="docutils literal"><span class="pre">spam</span></tt> package).</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.3.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.find_spec">
<tt class="descclassname">importlib.util.</tt><tt class="descname">find_spec</tt><big>(</big><em>name</em>, <em>package=None</em><big>)</big><a class="headerlink" href="#importlib.util.find_spec" title="Permalink to this definition">¶</a></dt>
<dd><p>Find the <a class="reference internal" href="../glossary.html#term-module-spec"><em class="xref std std-term">spec</em></a> for a module, optionally relative to
the specified <strong>package</strong> name. If the module is in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-attr docutils literal"><span class="pre">sys.modules</span></tt></a>,
then <tt class="docutils literal"><span class="pre">sys.modules[name].__spec__</span></tt> is returned (unless the spec would be
<tt class="docutils literal"><span class="pre">None</span></tt> or is not set, in which case <a class="reference internal" href="exceptions.html#ValueError" title="ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> is raised).
Otherwise a search using <a class="reference internal" href="sys.html#sys.meta_path" title="sys.meta_path"><tt class="xref py py-attr docutils literal"><span class="pre">sys.meta_path</span></tt></a> is done. <tt class="docutils literal"><span class="pre">None</span></tt> is
returned if no spec is found.</p>
<p>If <strong>name</strong> is for a submodule (contains a dot), the parent module is
automatically imported.</p>
<p><strong>name</strong> and <strong>package</strong> work the same as for <tt class="xref py py-func docutils literal"><span class="pre">import_module()</span></tt>.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.module_for_loader">
<tt class="descclassname">&#64;</tt><tt class="descclassname">importlib.util.</tt><tt class="descname">module_for_loader</tt><a class="headerlink" href="#importlib.util.module_for_loader" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="../glossary.html#term-decorator"><em class="xref std std-term">decorator</em></a> for <a class="reference internal" href="#importlib.abc.Loader.load_module" title="importlib.abc.Loader.load_module"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.Loader.load_module()</span></tt></a>
to handle selecting the proper
module object to load with. The decorated method is expected to have a call
signature taking two positional arguments
(e.g. <tt class="docutils literal"><span class="pre">load_module(self,</span> <span class="pre">module)</span></tt>) for which the second argument
will be the module <strong>object</strong> to be used by the loader.
Note that the decorator will not work on static methods because of the
assumption of two arguments.</p>
<p>The decorated method will take in the <strong>name</strong> of the module to be loaded
as expected for a <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a>. If the module is not found in
<a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a> then a new one is constructed. Regardless of where the
module came from, <a class="reference internal" href="../reference/import.html#__loader__" title="__loader__"><tt class="xref py py-attr docutils literal"><span class="pre">__loader__</span></tt></a> set to <strong>self</strong> and <a class="reference internal" href="../reference/import.html#__package__" title="__package__"><tt class="xref py py-attr docutils literal"><span class="pre">__package__</span></tt></a>
is set based on what <a class="reference internal" href="#importlib.abc.InspectLoader.is_package" title="importlib.abc.InspectLoader.is_package"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.InspectLoader.is_package()</span></tt></a> returns
(if available). These attributes are set unconditionally to support
reloading.</p>
<p>If an exception is raised by the decorated method and a module was added to
<a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a>, then the module will be removed to prevent a partially
initialized module from being in left in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a>. If the module
was already in <a class="reference internal" href="sys.html#sys.modules" title="sys.modules"><tt class="xref py py-data docutils literal"><span class="pre">sys.modules</span></tt></a> then it is left alone.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.3: </span><a class="reference internal" href="../reference/import.html#__loader__" title="__loader__"><tt class="xref py py-attr docutils literal"><span class="pre">__loader__</span></tt></a> and <a class="reference internal" href="../reference/import.html#__package__" title="__package__"><tt class="xref py py-attr docutils literal"><span class="pre">__package__</span></tt></a> are automatically set
(when possible).</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Set <a class="reference internal" href="../reference/import.html#__name__" title="__name__"><tt class="xref py py-attr docutils literal"><span class="pre">__name__</span></tt></a>, <a class="reference internal" href="../reference/import.html#__loader__" title="__loader__"><tt class="xref py py-attr docutils literal"><span class="pre">__loader__</span></tt></a> <a class="reference internal" href="../reference/import.html#__package__" title="__package__"><tt class="xref py py-attr docutils literal"><span class="pre">__package__</span></tt></a>
unconditionally to support reloading.</p>
</div>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>The import machinery now directly performs all the functionality
provided by this function.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.set_loader">
<tt class="descclassname">&#64;</tt><tt class="descclassname">importlib.util.</tt><tt class="descname">set_loader</tt><a class="headerlink" href="#importlib.util.set_loader" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="../glossary.html#term-decorator"><em class="xref std std-term">decorator</em></a> for <a class="reference internal" href="#importlib.abc.Loader.load_module" title="importlib.abc.Loader.load_module"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.Loader.load_module()</span></tt></a>
to set the <a class="reference internal" href="../reference/import.html#__loader__" title="__loader__"><tt class="xref py py-attr docutils literal"><span class="pre">__loader__</span></tt></a>
attribute on the returned module. If the attribute is already set the
decorator does nothing. It is assumed that the first positional argument to
the wrapped method (i.e. <tt class="docutils literal"><span class="pre">self</span></tt>) is what <a class="reference internal" href="../reference/import.html#__loader__" title="__loader__"><tt class="xref py py-attr docutils literal"><span class="pre">__loader__</span></tt></a> should be set
to.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 3.4: </span>Set <tt class="docutils literal"><span class="pre">__loader__</span></tt> if set to <tt class="docutils literal"><span class="pre">None</span></tt>, as if the attribute does not
exist.</p>
</div>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>The import machinery takes care of this automatically.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.set_package">
<tt class="descclassname">&#64;</tt><tt class="descclassname">importlib.util.</tt><tt class="descname">set_package</tt><a class="headerlink" href="#importlib.util.set_package" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="../glossary.html#term-decorator"><em class="xref std std-term">decorator</em></a> for <a class="reference internal" href="#importlib.abc.Loader.load_module" title="importlib.abc.Loader.load_module"><tt class="xref py py-meth docutils literal"><span class="pre">importlib.abc.Loader.load_module()</span></tt></a> to set the <a class="reference internal" href="../reference/import.html#__package__" title="__package__"><tt class="xref py py-attr docutils literal"><span class="pre">__package__</span></tt></a> attribute on the returned module. If <a class="reference internal" href="../reference/import.html#__package__" title="__package__"><tt class="xref py py-attr docutils literal"><span class="pre">__package__</span></tt></a>
is set and has a value other than <tt class="docutils literal"><span class="pre">None</span></tt> it will not be changed.</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.4: </span>The import machinery takes care of this automatically.</p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.spec_from_loader">
<tt class="descclassname">importlib.util.</tt><tt class="descname">spec_from_loader</tt><big>(</big><em>name</em>, <em>loader</em>, <em>*</em>, <em>origin=None</em>, <em>is_package=None</em><big>)</big><a class="headerlink" href="#importlib.util.spec_from_loader" title="Permalink to this definition">¶</a></dt>
<dd><p>A factory function for creating a <tt class="xref py py-class docutils literal"><span class="pre">ModuleSpec</span></tt> instance based
on a loader.  The parameters have the same meaning as they do for
ModuleSpec.  The function uses available <a class="reference internal" href="../glossary.html#term-loader"><em class="xref std std-term">loader</em></a> APIs, such as
<tt class="xref py py-meth docutils literal"><span class="pre">InspectLoader.is_package()</span></tt>, to fill in any missing
information on the spec.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

<dl class="function">
<dt id="importlib.util.spec_from_file_location">
<tt class="descclassname">importlib.util.</tt><tt class="descname">spec_from_file_location</tt><big>(</big><em>name</em>, <em>location</em>, <em>*</em>, <em>loader=None</em>, <em>submodule_search_locations=None</em><big>)</big><a class="headerlink" href="#importlib.util.spec_from_file_location" title="Permalink to this definition">¶</a></dt>
<dd><p>A factory function for creating a <tt class="xref py py-class docutils literal"><span class="pre">ModuleSpec</span></tt> instance based
on the path to a file.  Missing information will be filled in on the
spec by making use of loader APIs and by the implication that the
module will be file-based.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 3.4.</span></p>
</div>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">31.5. <tt class="docutils literal"><span class="pre">importlib</span></tt> &#8211; The implementation of <tt class="docutils literal"><span class="pre">import</span></tt></a><ul>
<li><a class="reference internal" href="#introduction">31.5.1. Introduction</a></li>
<li><a class="reference internal" href="#functions">31.5.2. Functions</a></li>
<li><a class="reference internal" href="#module-importlib.abc">31.5.3. <tt class="docutils literal"><span class="pre">importlib.abc</span></tt> &#8211; Abstract base classes related to import</a></li>
<li><a class="reference internal" href="#module-importlib.machinery">31.5.4. <tt class="docutils literal"><span class="pre">importlib.machinery</span></tt> &#8211; Importers and path hooks</a></li>
<li><a class="reference internal" href="#module-importlib.util">31.5.5. <tt class="docutils literal"><span class="pre">importlib.util</span></tt> &#8211; Utility code for importers</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="runpy.html"
                        title="previous chapter">31.4. <tt class="docutils literal"><span class="pre">runpy</span></tt> &#8212; Locating and executing Python modules</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="language.html"
                        title="next chapter">32. Python Language Services</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
  <li><a href="../bugs.html">Report a Bug</a></li>
  <li><a href="../_sources/library/importlib.txt"
         rel="nofollow">Show Source</a></li>
</ul>

<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="language.html" title="32. Python Language Services"
             >next</a> |</li>
        <li class="right" >
          <a href="runpy.html" title="31.4. runpy — Locating and executing Python modules"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &raquo;</li>
        <li>
          <a href="../index.html">3.4.3 Documentation</a> &raquo;
        </li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="modules.html" >31. Importing Modules</a> &raquo;</li> 
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2015, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Feb 25, 2015.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.2.3.
    </div>

  </body>
</html>

@KyuuKazami