1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
<html xmlns="http://www.w3.org/1999/xhtml">
7
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
9
<title>8.16. new — Creation of runtime internal objects — Python 2.7.11 documentation</title>
11
<link rel="stylesheet" href="../_static/classic.css" type="text/css" />
12
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
14
<script type="text/javascript">
15
var DOCUMENTATION_OPTIONS = {
18
COLLAPSE_INDEX: false,
23
<script type="text/javascript" src="../_static/jquery.js"></script>
24
<script type="text/javascript" src="../_static/underscore.js"></script>
25
<script type="text/javascript" src="../_static/doctools.js"></script>
26
<script type="text/javascript" src="../_static/sidebar.js"></script>
27
<link rel="search" type="application/opensearchdescription+xml"
28
title="Search within Python 2.7.11 documentation"
29
href="../_static/opensearch.xml"/>
30
<link rel="author" title="About these documents" href="../about.html" />
31
<link rel="copyright" title="Copyright" href="../copyright.html" />
32
<link rel="top" title="Python 2.7.11 documentation" href="../contents.html" />
33
<link rel="up" title="8. Data Types" href="datatypes.html" />
34
<link rel="next" title="8.17. copy — Shallow and deep copy operations" href="copy.html" />
35
<link rel="prev" title="8.15. types — Names for built-in types" href="types.html" />
36
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
37
<script type="text/javascript" src="../_static/copybutton.js"></script>
38
<script type="text/javascript" src="../_static/version_switch.js"></script>
43
<body role="document">
44
<div class="related" role="navigation" aria-label="related navigation">
47
<li class="right" style="margin-right: 10px">
48
<a href="../genindex.html" title="General Index"
49
accesskey="I">index</a></li>
51
<a href="../py-modindex.html" title="Python Module Index"
54
<a href="copy.html" title="8.17. copy — Shallow and deep copy operations"
55
accesskey="N">next</a> |</li>
57
<a href="types.html" title="8.15. types — Names for built-in types"
58
accesskey="P">previous</a> |</li>
59
<li><img src="../_static/py.png" alt=""
60
style="vertical-align: middle; margin-top: -1px"/></li>
61
<li><a href="https://www.python.org/">Python</a> »</li>
63
<span class="version_switcher_placeholder">2.7.11</span>
64
<a href="../index.html">Documentation</a> »
67
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
68
<li class="nav-item nav-item-2"><a href="datatypes.html" accesskey="U">8. Data Types</a> »</li>
72
<div class="document">
73
<div class="documentwrapper">
74
<div class="bodywrapper">
75
<div class="body" role="main">
77
<div class="section" id="module-new">
78
<span id="new-creation-of-runtime-internal-objects"></span><h1>8.16. <a class="reference internal" href="#module-new" title="new: Interface to the creation of runtime implementation objects. (deprecated)"><code class="xref py py-mod docutils literal"><span class="pre">new</span></code></a> — Creation of runtime internal objects<a class="headerlink" href="#module-new" title="Permalink to this headline">¶</a></h1>
79
<div class="deprecated">
80
<p><span class="versionmodified">Deprecated since version 2.6: </span>The <a class="reference internal" href="#module-new" title="new: Interface to the creation of runtime implementation objects. (deprecated)"><code class="xref py py-mod docutils literal"><span class="pre">new</span></code></a> module has been removed in Python 3. Use the <a class="reference internal" href="types.html#module-types" title="types: Names for built-in types."><code class="xref py py-mod docutils literal"><span class="pre">types</span></code></a>
81
module’s classes instead.</p>
83
<p>The <a class="reference internal" href="#module-new" title="new: Interface to the creation of runtime implementation objects. (deprecated)"><code class="xref py py-mod docutils literal"><span class="pre">new</span></code></a> module allows an interface to the interpreter object creation
84
functions. This is for use primarily in marshal-type functions, when a new
85
object needs to be created “magically” and not by using the regular creation
86
functions. This module provides a low-level interface to the interpreter, so
87
care must be exercised when using this module. It is possible to supply
88
non-sensical arguments which crash the interpreter when the object is used.</p>
89
<p>The <a class="reference internal" href="#module-new" title="new: Interface to the creation of runtime implementation objects. (deprecated)"><code class="xref py py-mod docutils literal"><span class="pre">new</span></code></a> module defines the following functions:</p>
91
<dt id="new.instance">
92
<code class="descclassname">new.</code><code class="descname">instance</code><span class="sig-paren">(</span><em>class</em><span class="optional">[</span>, <em>dict</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#new.instance" title="Permalink to this definition">¶</a></dt>
93
<dd><p>This function creates an instance of <em>class</em> with dictionary <em>dict</em> without
94
calling the <a class="reference internal" href="../reference/datamodel.html#object.__init__" title="object.__init__"><code class="xref py py-meth docutils literal"><span class="pre">__init__()</span></code></a> constructor. If <em>dict</em> is omitted or <code class="docutils literal"><span class="pre">None</span></code>, a
95
new, empty dictionary is created for the new instance. Note that there are no
96
guarantees that the object will be in a consistent state.</p>
100
<dt id="new.instancemethod">
101
<code class="descclassname">new.</code><code class="descname">instancemethod</code><span class="sig-paren">(</span><em>function</em>, <em>instance</em>, <em>class</em><span class="sig-paren">)</span><a class="headerlink" href="#new.instancemethod" title="Permalink to this definition">¶</a></dt>
102
<dd><p>This function will return a method object, bound to <em>instance</em>, or unbound if
103
<em>instance</em> is <code class="docutils literal"><span class="pre">None</span></code>. <em>function</em> must be callable.</p>
106
<dl class="function">
107
<dt id="new.function">
108
<code class="descclassname">new.</code><code class="descname">function</code><span class="sig-paren">(</span><em>code</em>, <em>globals</em><span class="optional">[</span>, <em>name</em><span class="optional">[</span>, <em>argdefs</em><span class="optional">[</span>, <em>closure</em><span class="optional">]</span><span class="optional">]</span><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#new.function" title="Permalink to this definition">¶</a></dt>
109
<dd><p>Returns a (Python) function with the given code and globals. If <em>name</em> is given,
110
it must be a string or <code class="docutils literal"><span class="pre">None</span></code>. If it is a string, the function will have the
111
given name, otherwise the function name will be taken from <code class="docutils literal"><span class="pre">code.co_name</span></code>. If
112
<em>argdefs</em> is given, it must be a tuple and will be used to determine the default
113
values of parameters. If <em>closure</em> is given, it must be <code class="docutils literal"><span class="pre">None</span></code> or a tuple of
114
cell objects containing objects to bind to the names in <code class="docutils literal"><span class="pre">code.co_freevars</span></code>.</p>
117
<dl class="function">
119
<code class="descclassname">new.</code><code class="descname">code</code><span class="sig-paren">(</span><em>argcount</em>, <em>nlocals</em>, <em>stacksize</em>, <em>flags</em>, <em>codestring</em>, <em>constants</em>, <em>names</em>, <em>varnames</em>, <em>filename</em>, <em>name</em>, <em>firstlineno</em>, <em>lnotab</em><span class="sig-paren">)</span><a class="headerlink" href="#new.code" title="Permalink to this definition">¶</a></dt>
120
<dd><p>This function is an interface to the <a class="reference internal" href="../c-api/code.html#c.PyCode_New" title="PyCode_New"><code class="xref c c-func docutils literal"><span class="pre">PyCode_New()</span></code></a> C function.</p>
123
<dl class="function">
125
<code class="descclassname">new.</code><code class="descname">module</code><span class="sig-paren">(</span><em>name</em><span class="optional">[</span>, <em>doc</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#new.module" title="Permalink to this definition">¶</a></dt>
126
<dd><p>This function returns a new module object with name <em>name</em>. <em>name</em> must be a
127
string. The optional <em>doc</em> argument can have any type.</p>
130
<dl class="function">
131
<dt id="new.classobj">
132
<code class="descclassname">new.</code><code class="descname">classobj</code><span class="sig-paren">(</span><em>name</em>, <em>baseclasses</em>, <em>dict</em><span class="sig-paren">)</span><a class="headerlink" href="#new.classobj" title="Permalink to this definition">¶</a></dt>
133
<dd><p>This function returns a new class object, with name <em>name</em>, derived from
134
<em>baseclasses</em> (which should be a tuple of classes) and with namespace <em>dict</em>.</p>
143
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
144
<div class="sphinxsidebarwrapper">
145
<h4>Previous topic</h4>
146
<p class="topless"><a href="types.html"
147
title="previous chapter">8.15. <code class="docutils literal"><span class="pre">types</span></code> — Names for built-in types</a></p>
149
<p class="topless"><a href="copy.html"
150
title="next chapter">8.17. <code class="docutils literal"><span class="pre">copy</span></code> — Shallow and deep copy operations</a></p>
152
<ul class="this-page-menu">
153
<li><a href="../bugs.html">Report a Bug</a></li>
154
<li><a href="../_sources/library/new.txt"
155
rel="nofollow">Show Source</a></li>
158
<div id="searchbox" style="display: none" role="search">
159
<h3>Quick search</h3>
160
<form class="search" action="../search.html" method="get">
161
<input type="text" name="q" />
162
<input type="submit" value="Go" />
163
<input type="hidden" name="check_keywords" value="yes" />
164
<input type="hidden" name="area" value="default" />
166
<p class="searchtip" style="font-size: 90%">
167
Enter search terms or a module, class or function name.
170
<script type="text/javascript">$('#searchbox').show(0);</script>
173
<div class="clearer"></div>
175
<div class="related" role="navigation" aria-label="related navigation">
178
<li class="right" style="margin-right: 10px">
179
<a href="../genindex.html" title="General Index"
182
<a href="../py-modindex.html" title="Python Module Index"
185
<a href="copy.html" title="8.17. copy — Shallow and deep copy operations"
188
<a href="types.html" title="8.15. types — Names for built-in types"
190
<li><img src="../_static/py.png" alt=""
191
style="vertical-align: middle; margin-top: -1px"/></li>
192
<li><a href="https://www.python.org/">Python</a> »</li>
194
<span class="version_switcher_placeholder">2.7.11</span>
195
<a href="../index.html">Documentation</a> »
198
<li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>
199
<li class="nav-item nav-item-2"><a href="datatypes.html" >8. Data Types</a> »</li>
203
© <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
205
The Python Software Foundation is a non-profit corporation.
206
<a href="https://www.python.org/psf/donations/">Please donate.</a>
208
Last updated on Jan 23, 2016.
209
<a href="../bugs.html">Found a bug</a>?
211
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
b'\\ No newline at end of file'