Sophie

Sophie

distrib > Mandriva > current > i586 > media > main-updates > by-pkgid > 8f1462e52e1797a02c97073eed0b7f92 > files > 822

python-docs-2.6.5-2.5mdv2010.2.i586.rpm

<!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>9.16. new — Creation of runtime internal objects &mdash; Python v2.6.5 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '2.6.5',
        COLLAPSE_MODINDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python v2.6.5 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 v2.6.5 documentation" href="../index.html" />
    <link rel="up" title="9. Data Types" href="datatypes.html" />
    <link rel="next" title="9.17. copy — Shallow and deep copy operations" href="copy.html" />
    <link rel="prev" title="9.15. types — Names for built-in types" href="types.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
 

  </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="../modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="copy.html" title="9.17. copy — Shallow and deep copy operations"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="types.html" title="9.15. types — Names for built-in types"
             accesskey="P">previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v2.6.5 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="datatypes.html" accesskey="U">9. Data Types</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-new">
<h1>9.16. <tt class="xref docutils literal"><span class="pre">new</span></tt> &#8212; Creation of runtime internal objects<a class="headerlink" href="#module-new" title="Permalink to this headline">¶</a></h1>
<p class="deprecated">
<span class="versionmodified">Deprecated since version 2.6: </span>The <tt class="xref docutils literal"><span class="pre">new</span></tt> module has been removed in Python 3.0.  Use the <a title="Names for built-in types." class="reference external" href="types.html#module-types"><tt class="xref docutils literal"><span class="pre">types</span></tt></a>
module&#8217;s classes instead.</p>
<p>The <tt class="xref docutils literal"><span class="pre">new</span></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 &#8220;magically&#8221; 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. It is possible to supply
non-sensical arguments which crash the interpreter when the object is used.</p>
<p>The <tt class="xref docutils literal"><span class="pre">new</span></tt> module defines the following functions:</p>
<dl class="function">
<dt id="new.instance">
<tt class="descclassname">new.</tt><tt class="descname">instance</tt><big>(</big><em>class</em><span class="optional">[</span>, <em>dict</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#new.instance" title="Permalink to this definition">¶</a></dt>
<dd>This function creates an instance of <em>class</em> with dictionary <em>dict</em> without
calling the <a title="object.__init__" class="reference external" href="../reference/datamodel.html#object.__init__"><tt class="xref docutils literal"><span class="pre">__init__()</span></tt></a> constructor.  If <em>dict</em> is omitted or <tt class="xref docutils literal"><span class="pre">None</span></tt>, a
new, empty dictionary is created for the new instance.  Note that there are no
guarantees that the object will be in a consistent state.</dd></dl>

<dl class="function">
<dt id="new.instancemethod">
<tt class="descclassname">new.</tt><tt class="descname">instancemethod</tt><big>(</big><em>function</em>, <em>instance</em>, <em>class</em><big>)</big><a class="headerlink" href="#new.instancemethod" title="Permalink to this definition">¶</a></dt>
<dd>This function will return a method object, bound to <em>instance</em>, or unbound if
<em>instance</em> is <tt class="xref docutils literal"><span class="pre">None</span></tt>.  <em>function</em> must be callable.</dd></dl>

<dl class="function">
<dt id="new.function">
<tt class="descclassname">new.</tt><tt class="descname">function</tt><big>(</big><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><big>)</big><a class="headerlink" href="#new.function" title="Permalink to this definition">¶</a></dt>
<dd>Returns a (Python) function with the given code and globals. If <em>name</em> is given,
it must be a string or <tt class="xref docutils literal"><span class="pre">None</span></tt>.  If it is a string, the function will have the
given name, otherwise the function name will be taken from <tt class="docutils literal"><span class="pre">code.co_name</span></tt>.  If
<em>argdefs</em> is given, it must be a tuple and will be used to determine the default
values of parameters.  If <em>closure</em> is given, it must be <tt class="xref docutils literal"><span class="pre">None</span></tt> or a tuple of
cell objects containing objects to bind to the names in <tt class="docutils literal"><span class="pre">code.co_freevars</span></tt>.</dd></dl>

<dl class="function">
<dt id="new.code">
<tt class="descclassname">new.</tt><tt class="descname">code</tt><big>(</big><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><big>)</big><a class="headerlink" href="#new.code" title="Permalink to this definition">¶</a></dt>
<dd>This function is an interface to the <tt class="xref docutils literal"><span class="pre">PyCode_New()</span></tt> C function.</dd></dl>

<dl class="function">
<dt id="new.module">
<tt class="descclassname">new.</tt><tt class="descname">module</tt><big>(</big><em>name</em><span class="optional">[</span>, <em>doc</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#new.module" title="Permalink to this definition">¶</a></dt>
<dd>This function returns a new module object with name <em>name</em>. <em>name</em> must be a
string. The optional <em>doc</em> argument can have any type.</dd></dl>

<dl class="function">
<dt id="new.classobj">
<tt class="descclassname">new.</tt><tt class="descname">classobj</tt><big>(</big><em>name</em>, <em>baseclasses</em>, <em>dict</em><big>)</big><a class="headerlink" href="#new.classobj" title="Permalink to this definition">¶</a></dt>
<dd>This function returns a new class object, with name <em>name</em>, derived from
<em>baseclasses</em> (which should be a tuple of classes) and with namespace <em>dict</em>.</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="types.html"
                                  title="previous chapter">9.15. <tt class="docutils literal"><span class="pre">types</span></tt> &#8212; Names for built-in types</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="copy.html"
                                  title="next chapter">9.17. <tt class="docutils literal docutils literal"><span class="pre">copy</span></tt> &#8212; Shallow and deep copy operations</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/library/new.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" size="18" />
                <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="../modindex.html" title="Global Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="copy.html" title="9.17. copy — Shallow and deep copy operations"
             >next</a> |</li>
        <li class="right" >
          <a href="types.html" title="9.15. types — Names for built-in types"
             >previous</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="../index.html">Python v2.6.5 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="datatypes.html" >9. Data Types</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2010, Python Software Foundation.
    <br />
    The Python Software Foundation is a non-profit corporation.  
    <a href="http://www.python.org/psf/donations/">Please donate.</a>
    <br />
    Last updated on Mar 19, 2010.
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.5.
    </div>

  </body>
</html>