📄 module-imp.html
字号:
<dd>
The module was found as dynamically loadable shared library.
</dl>
<P>
<dl><dt><b><a name='l2h-461'><tt>PY_RESOURCE</tt></a></b>
<dd>
The module was found as a Macintosh resource. This value can only be
returned on a Macintosh.
</dl>
<P>
<dl><dt><b><a name='l2h-462'><tt>PKG_DIRECTORY</tt></a></b>
<dd>
The module was found as a package directory.
</dl>
<P>
<dl><dt><b><a name='l2h-463'><tt>C_BUILTIN</tt></a></b>
<dd>
The module was found as a built-in module.
</dl>
<P>
<dl><dt><b><a name='l2h-464'><tt>PY_FROZEN</tt></a></b>
<dd>
The module was found as a frozen module (see <tt class="function">init_frozen()</tt>).
</dl>
<P>
The following constant and functions are obsolete; their functionality
is available through <tt class="function">find_module()</tt> or <tt class="function">load_module()</tt>.
They are kept around for backward compatibility:
<P>
<dl><dt><b><a name='l2h-465'><tt>SEARCH_ERROR</tt></a></b>
<dd>
Unused.
</dl>
<P>
<dl><dt><b><a name='l2h-466'><tt class='function'>init_builtin</tt></a></b> (<var>name</var>)
<dd>
Initialize the built-in module called <var>name</var> and return its module
object. If the module was already initialized, it will be initialized
<i>again</i>. A few modules cannot be initialized twice -- attempting
to initialize these again will raise an <tt class="exception">ImportError</tt>
exception. If there is no
built-in module called <var>name</var>, <code>None</code> is returned.
</dl>
<P>
<dl><dt><b><a name='l2h-467'><tt class='function'>init_frozen</tt></a></b> (<var>name</var>)
<dd>
Initialize the frozen module called <var>name</var> and return its module
object. If the module was already initialized, it will be initialized
<i>again</i>. If there is no frozen module called <var>name</var>,
<code>None</code> is returned. (Frozen modules are modules written in
Python whose compiled byte-code object is incorporated into a
custom-built Python interpreter by Python's <b class="program">freeze</b> utility.
See <span class="file">Tools/freeze/</span> for now.)
</dl>
<P>
<dl><dt><b><a name='l2h-468'><tt class='function'>is_builtin</tt></a></b> (<var>name</var>)
<dd>
Return <code>1</code> if there is a built-in module called <var>name</var> which
can be initialized again. Return <code>-1</code> if there is a built-in
module called <var>name</var> which cannot be initialized again (see
<tt class="function">init_builtin()</tt>). Return <code>0</code> if there is no built-in
module called <var>name</var>.
</dl>
<P>
<dl><dt><b><a name='l2h-469'><tt class='function'>is_frozen</tt></a></b> (<var>name</var>)
<dd>
Return <code>1</code> if there is a frozen module (see
<tt class="function">init_frozen()</tt>) called <var>name</var>, or <code>0</code> if there is
no such module.
</dl>
<P>
<dl><dt><b><a name='l2h-470'><tt class='function'>load_compiled</tt></a></b> (<var>name, pathname, file</var>)
<dd>
Load and initialize a module implemented as a byte-compiled code file
and return its module object. If the module was already initialized,
it will be initialized <i>again</i>. The <var>name</var> argument is used
to create or access a module object. The <var>pathname</var> argument
points to the byte-compiled code file. The <var>file</var>
argument is the byte-compiled code file, open for reading in binary
mode, from the beginning.
It must currently be a real file object, not a
user-defined class emulating a file.
</dl>
<P>
<dl><dt><b><a name='l2h-471'><tt class='function'>load_dynamic</tt></a></b> (<var>name, pathname</var><big>[</big><var>, file</var><big>]</big>)
<dd>
Load and initialize a module implemented as a dynamically loadable
shared library and return its module object. If the module was
already initialized, it will be initialized <i>again</i>. Some modules
don't like that and may raise an exception. The <var>pathname</var>
argument must point to the shared library. The <var>name</var> argument is
used to construct the name of the initialization function: an external
C function called "<tt class="samp">init<var>name</var>()</tt>" in the shared library is
called. The optional <var>file</var> argument is ignored. (Note: using
shared libraries is highly system dependent, and not all systems
support it.)
</dl>
<P>
<dl><dt><b><a name='l2h-472'><tt class='function'>load_source</tt></a></b> (<var>name, pathname, file</var>)
<dd>
Load and initialize a module implemented as a Python source file and
return its module object. If the module was already initialized, it
will be initialized <i>again</i>. The <var>name</var> argument is used to
create or access a module object. The <var>pathname</var> argument points
to the source file. The <var>file</var> argument is the source
file, open for reading as text, from the beginning.
It must currently be a real file
object, not a user-defined class emulating a file. Note that if a
properly matching byte-compiled file (with suffix <span class="file">.pyc</span> or
<span class="file">.pyo</span>) exists, it will be used instead of parsing the given
source file.
</dl>
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
<UL>
<LI><A NAME="tex2html1531"
href="examples-imp.html" tppabs="http://www.python.org/doc/current/lib/examples-imp.html">3.17.1 Examples</A>
</UL>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-marshal.html" tppabs="http://www.python.org/doc/current/lib/module-marshal.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="python.html" tppabs="http://www.python.org/doc/current/lib/python.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="examples-imp.html" tppabs="http://www.python.org/doc/current/lib/examples-imp.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-marshal.html" tppabs="http://www.python.org/doc/current/lib/module-marshal.html">3.16 marshal </A>
<b class="navlabel">Up:</b> <a class="sectref" href="python.html" tppabs="http://www.python.org/doc/current/lib/python.html">3. Python Runtime Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="examples-imp.html" tppabs="http://www.python.org/doc/current/lib/examples-imp.html">3.17.1 Examples</A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -