⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module-new.html

📁 一本很好的python的说明书,适合对python感兴趣的人
💻 HTML
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.22 new -- Creation of runtime internal objects</title>
<META NAME="description" CONTENT="3.22 new -- Creation of runtime internal objects">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" href="lib.css" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-site.html" tppabs="http://www.python.org/doc/current/lib/module-site.html">
<LINK REL="previous" href="module-repr.html" tppabs="http://www.python.org/doc/current/lib/module-repr.html">
<LINK REL="up" href="python.html" tppabs="http://www.python.org/doc/current/lib/python.html">
<LINK REL="next" href="module-site.html" tppabs="http://www.python.org/doc/current/lib/module-site.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="subclassing-reprs.html" tppabs="http://www.python.org/doc/current/lib/subclassing-reprs.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="module-site.html" tppabs="http://www.python.org/doc/current/lib/module-site.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="subclassing-reprs.html" tppabs="http://www.python.org/doc/current/lib/subclassing-reprs.html">3.21.2 Subclassing Repr Objects</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="module-site.html" tppabs="http://www.python.org/doc/current/lib/module-site.html">3.23 site  </A>
<br><hr></DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0052200000000000000000">
3.22 <tt class="module">new</tt> --
         Creation of runtime internal objects</A>
</H1>

<P>


<P>
The <tt class="module">new</tt> module allows an interface to the interpreter object
creation functions. This is for use primarily in marshal-type functions,
when a new object needs to be created ``magically'' and not by using the
regular creation functions. This module provides a low-level interface
to the interpreter, so care must be exercised when using this module.

<P>
The <tt class="module">new</tt> module defines the following functions:

<P>
<dl><dt><b><a name='l2h-522'><tt class='function'>instance</tt></a></b> (<var>class, dict</var>)
<dd>
This function creates an instance of <var>class</var> with dictionary
<var>dict</var> without calling the <tt class="method">__init__()</tt> constructor. Note that
there are no guarantees that the object will be in a consistent state.
</dl>

<P>
<dl><dt><b><a name='l2h-523'><tt class='function'>instancemethod</tt></a></b> (<var>function, instance, class</var>)
<dd>
This function will return a method object, bound to <var>instance</var>, or
unbound if <var>instance</var> is <code>None</code>.  <var>function</var> must be
callable, and <var>instance</var> must be an instance object or
<code>None</code>.
</dl>

<P>
<dl><dt><b><a name='l2h-524'><tt class='function'>function</tt></a></b> (<var>code, globals</var><big>[</big><var>, name</var><big>[</big><var>, argdefs</var><big>]</big><big>]</big>)
<dd>
Returns a (Python) function with the given code and globals. If
<var>name</var> is given, it must be a string or <code>None</code>.  If it is a
string, the function will have the given name, otherwise the function
name will be taken from <code><var>code</var>.co_name</code>.  If
<var>argdefs</var> is given, it must be a tuple and will be used to
determine the default values of parameters.
</dl>

<P>
<dl><dt><b><a name='l2h-525'><tt class='function'>code</tt></a></b> (<var>argcount, nlocals, stacksize, flags, codestring,
                       constants, names, varnames, filename, name, firstlineno,
                       lnotab</var>)
<dd>
This function is an interface to the <tt class="cfunction">PyCode_New()</tt> C
function.
</dl>

<P>
<dl><dt><b><a name='l2h-526'><tt class='function'>module</tt></a></b> (<var>name</var>)
<dd>
This function returns a new module object with name <var>name</var>.
<var>name</var> must be a string.
</dl>

<P>
<dl><dt><b><a name='l2h-527'><tt class='function'>classobj</tt></a></b> (<var>name, baseclasses, dict</var>)
<dd>
This function returns a new class object, with name <var>name</var>, derived
from <var>baseclasses</var> (which should be a tuple of classes) and with
namespace <var>dict</var>.
</dl>

<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="subclassing-reprs.html" tppabs="http://www.python.org/doc/current/lib/subclassing-reprs.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="module-site.html" tppabs="http://www.python.org/doc/current/lib/module-site.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="subclassing-reprs.html" tppabs="http://www.python.org/doc/current/lib/subclassing-reprs.html">3.21.2 Subclassing Repr Objects</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="module-site.html" tppabs="http://www.python.org/doc/current/lib/module-site.html">3.23 site  </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 + -