~dkuhlman/python-training-materials/Materials

« back to all changes in this revision

Viewing changes to python-2.7.11-docs-html/library/new.html

  • Committer: Dave Kuhlman
  • Date: 2017-04-15 16:24:56 UTC
  • Revision ID: dkuhlman@davekuhlman.org-20170415162456-iav9vozzg4iwqwv3
Updated docs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
 
 
4
 
 
5
 
<html xmlns="http://www.w3.org/1999/xhtml">
6
 
  <head>
7
 
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
8
 
    
9
 
    <title>8.16. new — Creation of runtime internal objects &mdash; Python 2.7.11 documentation</title>
10
 
    
11
 
    <link rel="stylesheet" href="../_static/classic.css" type="text/css" />
12
 
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
13
 
    
14
 
    <script type="text/javascript">
15
 
      var DOCUMENTATION_OPTIONS = {
16
 
        URL_ROOT:    '../',
17
 
        VERSION:     '2.7.11',
18
 
        COLLAPSE_INDEX: false,
19
 
        FILE_SUFFIX: '.html',
20
 
        HAS_SOURCE:  true
21
 
      };
22
 
    </script>
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>
39
 
 
40
 
    
41
 
 
42
 
  </head>
43
 
  <body role="document">  
44
 
    <div class="related" role="navigation" aria-label="related navigation">
45
 
      <h3>Navigation</h3>
46
 
      <ul>
47
 
        <li class="right" style="margin-right: 10px">
48
 
          <a href="../genindex.html" title="General Index"
49
 
             accesskey="I">index</a></li>
50
 
        <li class="right" >
51
 
          <a href="../py-modindex.html" title="Python Module Index"
52
 
             >modules</a> |</li>
53
 
        <li class="right" >
54
 
          <a href="copy.html" title="8.17. copy — Shallow and deep copy operations"
55
 
             accesskey="N">next</a> |</li>
56
 
        <li class="right" >
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> &raquo;</li>
62
 
        <li>
63
 
          <span class="version_switcher_placeholder">2.7.11</span>
64
 
          <a href="../index.html">Documentation</a> &raquo;
65
 
        </li>
66
 
 
67
 
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
68
 
          <li class="nav-item nav-item-2"><a href="datatypes.html" accesskey="U">8. Data Types</a> &raquo;</li> 
69
 
      </ul>
70
 
    </div>    
71
 
 
72
 
    <div class="document">
73
 
      <div class="documentwrapper">
74
 
        <div class="bodywrapper">
75
 
          <div class="body" role="main">
76
 
            
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> &#8212; 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&#8217;s classes instead.</p>
82
 
</div>
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 &#8220;magically&#8221; 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>
90
 
<dl class="function">
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>
97
 
</dd></dl>
98
 
 
99
 
<dl class="function">
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>
104
 
</dd></dl>
105
 
 
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>
115
 
</dd></dl>
116
 
 
117
 
<dl class="function">
118
 
<dt id="new.code">
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>
121
 
</dd></dl>
122
 
 
123
 
<dl class="function">
124
 
<dt id="new.module">
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>
128
 
</dd></dl>
129
 
 
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>
135
 
</dd></dl>
136
 
 
137
 
</div>
138
 
 
139
 
 
140
 
          </div>
141
 
        </div>
142
 
      </div>
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> &#8212; Names for built-in types</a></p>
148
 
  <h4>Next topic</h4>
149
 
  <p class="topless"><a href="copy.html"
150
 
                        title="next chapter">8.17. <code class="docutils literal"><span class="pre">copy</span></code> &#8212; Shallow and deep copy operations</a></p>
151
 
<h3>This Page</h3>
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>
156
 
</ul>
157
 
 
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" />
165
 
    </form>
166
 
    <p class="searchtip" style="font-size: 90%">
167
 
    Enter search terms or a module, class or function name.
168
 
    </p>
169
 
</div>
170
 
<script type="text/javascript">$('#searchbox').show(0);</script>
171
 
        </div>
172
 
      </div>
173
 
      <div class="clearer"></div>
174
 
    </div>  
175
 
    <div class="related" role="navigation" aria-label="related navigation">
176
 
      <h3>Navigation</h3>
177
 
      <ul>
178
 
        <li class="right" style="margin-right: 10px">
179
 
          <a href="../genindex.html" title="General Index"
180
 
             >index</a></li>
181
 
        <li class="right" >
182
 
          <a href="../py-modindex.html" title="Python Module Index"
183
 
             >modules</a> |</li>
184
 
        <li class="right" >
185
 
          <a href="copy.html" title="8.17. copy — Shallow and deep copy operations"
186
 
             >next</a> |</li>
187
 
        <li class="right" >
188
 
          <a href="types.html" title="8.15. types — Names for built-in types"
189
 
             >previous</a> |</li>
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> &raquo;</li>
193
 
        <li>
194
 
          <span class="version_switcher_placeholder">2.7.11</span>
195
 
          <a href="../index.html">Documentation</a> &raquo;
196
 
        </li>
197
 
 
198
 
          <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> &raquo;</li>
199
 
          <li class="nav-item nav-item-2"><a href="datatypes.html" >8. Data Types</a> &raquo;</li> 
200
 
      </ul>
201
 
    </div>  
202
 
    <div class="footer">
203
 
    &copy; <a href="../copyright.html">Copyright</a> 1990-2016, Python Software Foundation.
204
 
    <br />
205
 
    The Python Software Foundation is a non-profit corporation.
206
 
    <a href="https://www.python.org/psf/donations/">Please donate.</a>
207
 
    <br />
208
 
    Last updated on Jan 23, 2016.
209
 
    <a href="../bugs.html">Found a bug</a>?
210
 
    <br />
211
 
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.3.3.
212
 
    </div>
213
 
 
214
 
  </body>
215
 
</html>
 
 
b'\\ No newline at end of file'