Sophie

Sophie

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

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>List 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="Concrete Objects Layer" href="concrete.html" />
    <link rel="next" title="Dictionary Objects" href="dict.html" />
    <link rel="prev" title="Tuple Objects" href="tuple.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="dict.html" title="Dictionary Objects"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="tuple.html" title="Tuple Objects"
             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" >Python/C API Reference Manual</a> &raquo;</li>
          <li><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="list-objects">
<span id="listobjects"></span><h1>List Objects<a class="headerlink" href="#list-objects" title="Permalink to this headline">¶</a></h1>
<span class="target" id="index-96"></span><dl class="ctype">
<dt id="PyListObject">
<tt class="descname">PyListObject</tt><a class="headerlink" href="#PyListObject" title="Permalink to this definition">¶</a></dt>
<dd>This subtype of <a title="PyObject" class="reference external" href="structures.html#PyObject"><tt class="xref docutils literal"><span class="pre">PyObject</span></tt></a> represents a Python list object.</dd></dl>

<dl class="cvar">
<dt id="PyList_Type">
<a title="PyTypeObject" class="reference external" href="type.html#PyTypeObject">PyTypeObject</a> <tt class="descname">PyList_Type</tt><a class="headerlink" href="#PyList_Type" title="Permalink to this definition">¶</a></dt>
<dd><p id="index-97">This instance of <a title="PyTypeObject" class="reference external" href="type.html#PyTypeObject"><tt class="xref docutils literal"><span class="pre">PyTypeObject</span></tt></a> represents the Python list type.
This is the same object as <tt class="docutils literal"><span class="pre">list</span></tt> and <tt class="docutils literal"><span class="pre">types.ListType</span></tt> in the Python
layer.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_Check">
int <tt class="descname">PyList_Check</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *p</em><big>)</big><a class="headerlink" href="#PyList_Check" title="Permalink to this definition">¶</a></dt>
<dd><p>Return true if <em>p</em> is a list object or an instance of a subtype of the list
type.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.2: </span>Allowed subtypes to be accepted.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_CheckExact">
int <tt class="descname">PyList_CheckExact</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *p</em><big>)</big><a class="headerlink" href="#PyList_CheckExact" title="Permalink to this definition">¶</a></dt>
<dd><p>Return true if <em>p</em> is a list object, but not an instance of a subtype of
the list type.</p>
<p class="versionadded">
<span class="versionmodified">New in version 2.2.</span></p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_New">
<a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a>* <tt class="descname">PyList_New</tt><big>(</big>Py_ssize_t<em> len</em><big>)</big><a class="headerlink" href="#PyList_New" title="Permalink to this definition">¶</a></dt>
<dd><em class="refcount">Return value: New reference.</em><p>Return a new list of length <em>len</em> on success, or <em>NULL</em> on failure.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If <em>length</em> is greater than zero, the returned list object&#8217;s items are
set to <tt class="docutils literal"><span class="pre">NULL</span></tt>.  Thus you cannot use abstract API functions such as
<a title="PySequence_SetItem" class="reference external" href="sequence.html#PySequence_SetItem"><tt class="xref docutils literal"><span class="pre">PySequence_SetItem()</span></tt></a>  or expose the object to Python code before
setting all items to a real object with <a title="PyList_SetItem" class="reference internal" href="#PyList_SetItem"><tt class="xref docutils literal"><span class="pre">PyList_SetItem()</span></tt></a>.</p>
</div>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This function used an <tt class="xref docutils literal"><span class="pre">int</span></tt> for <em>size</em>. This might require
changes in your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_Size">
Py_ssize_t <tt class="descname">PyList_Size</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em><big>)</big><a class="headerlink" href="#PyList_Size" title="Permalink to this definition">¶</a></dt>
<dd><p id="index-98">Return the length of the list object in <em>list</em>; this is equivalent to
<tt class="docutils literal"><span class="pre">len(list)</span></tt> on a list object.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This function returned an <tt class="xref docutils literal"><span class="pre">int</span></tt>. This might require changes in
your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_GET_SIZE">
Py_ssize_t <tt class="descname">PyList_GET_SIZE</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em><big>)</big><a class="headerlink" href="#PyList_GET_SIZE" title="Permalink to this definition">¶</a></dt>
<dd><p>Macro form of <a title="PyList_Size" class="reference internal" href="#PyList_Size"><tt class="xref docutils literal"><span class="pre">PyList_Size()</span></tt></a> without error checking.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This macro returned an <tt class="xref docutils literal"><span class="pre">int</span></tt>. This might require changes in your
code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_GetItem">
<a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a>* <tt class="descname">PyList_GetItem</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em>, Py_ssize_t<em> index</em><big>)</big><a class="headerlink" href="#PyList_GetItem" title="Permalink to this definition">¶</a></dt>
<dd><em class="refcount">Return value: Borrowed reference.</em><p>Return the object at position <em>pos</em> in the list pointed to by <em>p</em>.  The
position must be positive, indexing from the end of the list is not
supported.  If <em>pos</em> is out of bounds, return <em>NULL</em> and set an
<a title="exceptions.IndexError" class="reference external" href="../library/exceptions.html#exceptions.IndexError"><tt class="xref docutils literal"><span class="pre">IndexError</span></tt></a> exception.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This function used an <tt class="xref docutils literal"><span class="pre">int</span></tt> for <em>index</em>. This might require
changes in your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_GET_ITEM">
<a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a>* <tt class="descname">PyList_GET_ITEM</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em>, Py_ssize_t<em> i</em><big>)</big><a class="headerlink" href="#PyList_GET_ITEM" title="Permalink to this definition">¶</a></dt>
<dd><em class="refcount">Return value: Borrowed reference.</em><p>Macro form of <a title="PyList_GetItem" class="reference internal" href="#PyList_GetItem"><tt class="xref docutils literal"><span class="pre">PyList_GetItem()</span></tt></a> without error checking.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This macro used an <tt class="xref docutils literal"><span class="pre">int</span></tt> for <em>i</em>. This might require changes in
your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_SetItem">
int <tt class="descname">PyList_SetItem</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em>, Py_ssize_t<em> index</em>, <a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *item</em><big>)</big><a class="headerlink" href="#PyList_SetItem" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the item at index <em>index</em> in list to <em>item</em>.  Return <tt class="docutils literal"><span class="pre">0</span></tt> on success
or <tt class="docutils literal"><span class="pre">-1</span></tt> on failure.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function &#8220;steals&#8221; a reference to <em>item</em> and discards a reference to
an item already in the list at the affected position.</p>
</div>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This function used an <tt class="xref docutils literal"><span class="pre">int</span></tt> for <em>index</em>. This might require
changes in your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_SET_ITEM">
void <tt class="descname">PyList_SET_ITEM</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em>, Py_ssize_t<em> i</em>, <a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *o</em><big>)</big><a class="headerlink" href="#PyList_SET_ITEM" title="Permalink to this definition">¶</a></dt>
<dd><p>Macro form of <a title="PyList_SetItem" class="reference internal" href="#PyList_SetItem"><tt class="xref docutils literal"><span class="pre">PyList_SetItem()</span></tt></a> without error checking. This is
normally only used to fill in new lists where there is no previous content.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This macro &#8220;steals&#8221; a reference to <em>item</em>, and, unlike
<a title="PyList_SetItem" class="reference internal" href="#PyList_SetItem"><tt class="xref docutils literal"><span class="pre">PyList_SetItem()</span></tt></a>, does <em>not</em> discard a reference to any item that
it being replaced; any reference in <em>list</em> at position <em>i</em> will be
leaked.</p>
</div>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This macro used an <tt class="xref docutils literal"><span class="pre">int</span></tt> for <em>i</em>. This might require
changes in your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_Insert">
int <tt class="descname">PyList_Insert</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em>, Py_ssize_t<em> index</em>, <a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *item</em><big>)</big><a class="headerlink" href="#PyList_Insert" title="Permalink to this definition">¶</a></dt>
<dd><p>Insert the item <em>item</em> into list <em>list</em> in front of index <em>index</em>.  Return
<tt class="docutils literal"><span class="pre">0</span></tt> if successful; return <tt class="docutils literal"><span class="pre">-1</span></tt> and set an exception if unsuccessful.
Analogous to <tt class="docutils literal"><span class="pre">list.insert(index,</span> <span class="pre">item)</span></tt>.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This function used an <tt class="xref docutils literal"><span class="pre">int</span></tt> for <em>index</em>. This might require
changes in your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_Append">
int <tt class="descname">PyList_Append</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em>, <a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *item</em><big>)</big><a class="headerlink" href="#PyList_Append" title="Permalink to this definition">¶</a></dt>
<dd>Append the object <em>item</em> at the end of list <em>list</em>. Return <tt class="docutils literal"><span class="pre">0</span></tt> if
successful; return <tt class="docutils literal"><span class="pre">-1</span></tt> and set an exception if unsuccessful.  Analogous
to <tt class="docutils literal"><span class="pre">list.append(item)</span></tt>.</dd></dl>

<dl class="cfunction">
<dt id="PyList_GetSlice">
<a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a>* <tt class="descname">PyList_GetSlice</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em>, Py_ssize_t<em> low</em>, Py_ssize_t<em> high</em><big>)</big><a class="headerlink" href="#PyList_GetSlice" title="Permalink to this definition">¶</a></dt>
<dd><em class="refcount">Return value: New reference.</em><p>Return a list of the objects in <em>list</em> containing the objects <em>between</em> <em>low</em>
and <em>high</em>.  Return <em>NULL</em> and set an exception if unsuccessful.  Analogous
to <tt class="docutils literal"><span class="pre">list[low:high]</span></tt>.  Negative indices, as when slicing from Python, are not
supported.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This function used an <tt class="xref docutils literal"><span class="pre">int</span></tt> for <em>low</em> and <em>high</em>. This might
require changes in your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_SetSlice">
int <tt class="descname">PyList_SetSlice</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em>, Py_ssize_t<em> low</em>, Py_ssize_t<em> high</em>, <a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *itemlist</em><big>)</big><a class="headerlink" href="#PyList_SetSlice" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the slice of <em>list</em> between <em>low</em> and <em>high</em> to the contents of
<em>itemlist</em>.  Analogous to <tt class="docutils literal"><span class="pre">list[low:high]</span> <span class="pre">=</span> <span class="pre">itemlist</span></tt>. The <em>itemlist</em> may
be <em>NULL</em>, indicating the assignment of an empty list (slice deletion).
Return <tt class="docutils literal"><span class="pre">0</span></tt> on success, <tt class="docutils literal"><span class="pre">-1</span></tt> on failure.  Negative indices, as when
slicing from Python, are not supported.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>This function used an <tt class="xref docutils literal"><span class="pre">int</span></tt> for <em>low</em> and <em>high</em>. This might
require changes in your code for properly supporting 64-bit systems.</p>
</dd></dl>

<dl class="cfunction">
<dt id="PyList_Sort">
int <tt class="descname">PyList_Sort</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em><big>)</big><a class="headerlink" href="#PyList_Sort" title="Permalink to this definition">¶</a></dt>
<dd>Sort the items of <em>list</em> in place.  Return <tt class="docutils literal"><span class="pre">0</span></tt> on success, <tt class="docutils literal"><span class="pre">-1</span></tt> on
failure.  This is equivalent to <tt class="docutils literal"><span class="pre">list.sort()</span></tt>.</dd></dl>

<dl class="cfunction">
<dt id="PyList_Reverse">
int <tt class="descname">PyList_Reverse</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em><big>)</big><a class="headerlink" href="#PyList_Reverse" title="Permalink to this definition">¶</a></dt>
<dd>Reverse the items of <em>list</em> in place.  Return <tt class="docutils literal"><span class="pre">0</span></tt> on success, <tt class="docutils literal"><span class="pre">-1</span></tt> on
failure.  This is the equivalent of <tt class="docutils literal"><span class="pre">list.reverse()</span></tt>.</dd></dl>

<dl class="cfunction">
<dt id="PyList_AsTuple">
<a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a>* <tt class="descname">PyList_AsTuple</tt><big>(</big><a title="PyObject" class="reference external" href="structures.html#PyObject">PyObject</a><em> *list</em><big>)</big><a class="headerlink" href="#PyList_AsTuple" title="Permalink to this definition">¶</a></dt>
<dd><em class="refcount">Return value: New reference.</em><p id="index-99">Return a new tuple object containing the contents of <em>list</em>; equivalent to
<tt class="docutils literal"><span class="pre">tuple(list)</span></tt>.</p>
</dd></dl>

</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="tuple.html"
                                  title="previous chapter">Tuple Objects</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="dict.html"
                                  title="next chapter">Dictionary Objects</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/c-api/list.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="dict.html" title="Dictionary Objects"
             >next</a> |</li>
        <li class="right" >
          <a href="tuple.html" title="Tuple Objects"
             >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" >Python/C API Reference Manual</a> &raquo;</li>
          <li><a href="concrete.html" >Concrete Objects Layer</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>