/html/c-api/list.html
HTML | 272 lines | 244 code | 28 blank | 0 comment | 0 complexity | 93d9051f23a5b6df7722643f6b45ad14 MD5 | raw file
Possible License(s): BSD-3-Clause
- <!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 — Documentação Python v3.1c1</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: '3.1c1',
- 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 Documentação Python v3.1c1"
- 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="Documentação Python v3.1c1" 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="Índice Geral"
- accesskey="I">índice</a></li>
- <li class="right" >
- <a href="../modindex.html" title="Índice Global de Móodulos"
- accesskey="M">módulos</a> |</li>
- <li class="right" >
- <a href="dict.html" title="Dictionary Objects"
- accesskey="N">próximo</a> |</li>
- <li class="right" >
- <a href="tuple.html" title="Tuple Objects"
- accesskey="P">anterior</a> |</li>
- <li><img src="../_static/py.png" alt=""
- style="vertical-align: middle; margin-top: -1px"/></li>
- <li><a href="../index.html">Documentação Python v3.1c1</a> »</li>
- <li><a href="index.html" >Python/C API Reference Manual</a> »</li>
- <li><a href="concrete.html" accesskey="U">Concrete Objects Layer</a> »</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-85"></span><dl class="ctype">
- <dt id="PyListObject">
- <tt class="descname">PyListObject</tt><a class="headerlink" href="#PyListObject" title="Link permanente para esta definição">¶</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="Link permanente para esta definição">¶</a></dt>
- <dd><p id="index-86">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="Link permanente para esta definição">¶</a></dt>
- <dd>Return true if <em>p</em> is a list object or an instance of a subtype of the list
- type.</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="Link permanente para esta definição">¶</a></dt>
- <dd>Return true if <em>p</em> is a list object, but not an instance of a subtype of
- the list type.</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="Link permanente para esta definição">¶</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’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>
- </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="Link permanente para esta definição">¶</a></dt>
- <dd><p id="index-87">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>
- </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="Link permanente para esta definição">¶</a></dt>
- <dd>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.</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="Link permanente para esta definição">¶</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>
- </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="Link permanente para esta definição">¶</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>
- </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="Link permanente para esta definição">¶</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 “steals” a reference to <em>item</em> and discards a reference to
- an item already in the list at the affected position.</p>
- </div>
- </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="Link permanente para esta definição">¶</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 “steals” 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
- is being replaced; any reference in <em>list</em> at position <em>i</em> will be
- leaked.</p>
- </div>
- </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="Link permanente para esta definição">¶</a></dt>
- <dd>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>.</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="Link permanente para esta definição">¶</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="Link permanente para esta definição">¶</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>.</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="Link permanente para esta definição">¶</a></dt>
- <dd>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.</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="Link permanente para esta definição">¶</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="Link permanente para esta definição">¶</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="Link permanente para esta definição">¶</a></dt>
- <dd><em class="refcount">Return value: New reference.</em><p id="index-88">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>Tópico anterior</h4>
- <p class="topless"><a href="tuple.html"
- title="capítulo anterior">Tuple Objects</a></p>
- <h4>Próximo tópico</h4>
- <p class="topless"><a href="dict.html"
- title="próximo capítulo">Dictionary Objects</a></p>
- <h3>Esta página</h3>
- <ul class="this-page-menu">
- <li><a href="../_sources/c-api/list.txt"
- rel="nofollow">Mostrar fonte</a></li>
- </ul>
- <div id="searchbox" style="display: none">
- <h3>Busca rápida</h3>
- <form class="search" action="../search.html" method="get">
- <input type="text" name="q" size="18" />
- <input type="submit" value="Ir" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- <p class="searchtip" style="font-size: 90%">
- Informe o termo, módulo, classe ou nome de função para buscar.
- </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="Índice Geral"
- >índice</a></li>
- <li class="right" >
- <a href="../modindex.html" title="Índice Global de Móodulos"
- >módulos</a> |</li>
- <li class="right" >
- <a href="dict.html" title="Dictionary Objects"
- >próximo</a> |</li>
- <li class="right" >
- <a href="tuple.html" title="Tuple Objects"
- >anterior</a> |</li>
- <li><img src="../_static/py.png" alt=""
- style="vertical-align: middle; margin-top: -1px"/></li>
- <li><a href="../index.html">Documentação Python v3.1c1</a> »</li>
- <li><a href="index.html" >Python/C API Reference Manual</a> »</li>
- <li><a href="concrete.html" >Concrete Objects Layer</a> »</li>
- </ul>
- </div>
- <div class="footer">
- © <a href="../copyright.html">Copyright</a> 1990-2009, Python Software Foundation.
- Atualizado em Jun 28, 2009.
- Criado usando <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.1.
- </div>
- </body>
- </html>