Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / api / iterator-objects.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="api.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="api.html" title='Python/C API Reference Manual' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="descriptor-objects.html" />
13<link rel="prev" href="moduleObjects.html" />
14<link rel="parent" href="otherObjects.html" />
15<link rel="next" href="descriptor-objects.html" />
16<meta name='aesop' content='information' />
17<title>7.5.5 Iterator Objects </title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="7.5.4 Module Objects"
25 href="moduleObjects.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="7.5 Other Objects"
28 href="otherObjects.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="7.5.6 Descriptor Objects"
31 href="descriptor-objects.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python/C API Reference Manual</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><img src='../icons/blank.png'
38 border='0' height='32' alt='' width='32' /></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="moduleObjects.html">7.5.4 Module Objects</A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="otherObjects.html">7.5 Other Objects</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="descriptor-objects.html">7.5.6 Descriptor Objects</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H2><A NAME="SECTION009550000000000000000"></A><A NAME="iterator-objects"></A>
56<BR>
577.5.5 Iterator Objects
58</H2>
59
60<P>
61Python provides two general-purpose iterator objects. The first, a
62sequence iterator, works with an arbitrary sequence supporting the
63<tt class="method">__getitem__()</tt> method. The second works with a callable
64object and a sentinel value, calling the callable for each item in the
65sequence, and ending the iteration when the sentinel value is
66returned.
67
68<P>
69<dl><dt>PyTypeObject <b><tt id='l2h-697' xml:id='l2h-697' class="cdata">PySeqIter_Type</tt></b></dt>
70<dd>
71 Type object for iterator objects returned by
72 <tt class="cfunction">PySeqIter_New()</tt> and the one-argument form of the
73 <tt class="function">iter()</tt> built-in function for built-in sequence types.
74
75<span class="versionnote">New in version 2.2.</span>
76
77</dd></dl>
78
79<P>
80<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int&nbsp;<b><tt id='l2h-698' xml:id='l2h-698' class="cfunction">PySeqIter_Check</tt></b>(</nobr></td><td>op)</td></tr></table></dt>
81<dd>
82 Return true if the type of <var>op</var> is <tt class="cdata">PySeqIter_Type</tt>.
83
84<span class="versionnote">New in version 2.2.</span>
85
86</dd></dl>
87
88<P>
89<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-699' xml:id='l2h-699' class="cfunction">PySeqIter_New</tt></b>(</nobr></td><td>PyObject *<var>seq</var>)</td></tr></table></dt>
90<dd>
91<div class="refcount-info">
92 <span class="label">Return value:</span>
93 <span class="value">New reference.</span>
94</div>
95 Return an iterator that works with a general sequence object,
96 <var>seq</var>. The iteration ends when the sequence raises
97 <tt class="exception">IndexError</tt> for the subscripting operation.
98
99<span class="versionnote">New in version 2.2.</span>
100
101</dd></dl>
102
103<P>
104<dl><dt>PyTypeObject <b><tt id='l2h-700' xml:id='l2h-700' class="cdata">PyCallIter_Type</tt></b></dt>
105<dd>
106 Type object for iterator objects returned by
107 <tt class="cfunction">PyCallIter_New()</tt> and the two-argument form of the
108 <tt class="function">iter()</tt> built-in function.
109
110<span class="versionnote">New in version 2.2.</span>
111
112</dd></dl>
113
114<P>
115<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>int&nbsp;<b><tt id='l2h-701' xml:id='l2h-701' class="cfunction">PyCallIter_Check</tt></b>(</nobr></td><td>op)</td></tr></table></dt>
116<dd>
117 Return true if the type of <var>op</var> is <tt class="cdata">PyCallIter_Type</tt>.
118
119<span class="versionnote">New in version 2.2.</span>
120
121</dd></dl>
122
123<P>
124<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline"><td><nobr>PyObject*&nbsp;<b><tt id='l2h-702' xml:id='l2h-702' class="cfunction">PyCallIter_New</tt></b>(</nobr></td><td>PyObject *<var>callable</var>,
125 PyObject *<var>sentinel</var>)</td></tr></table></dt>
126<dd>
127<div class="refcount-info">
128 <span class="label">Return value:</span>
129 <span class="value">New reference.</span>
130</div>
131 Return a new iterator. The first parameter, <var>callable</var>, can be
132 any Python callable object that can be called with no parameters;
133 each call to it should return the next item in the iteration. When
134 <var>callable</var> returns a value equal to <var>sentinel</var>, the
135 iteration will be terminated.
136
137<span class="versionnote">New in version 2.2.</span>
138
139</dd></dl>
140
141<P>
142
143<DIV CLASS="navigation">
144<div class='online-navigation'>
145<p></p><hr />
146<table align="center" width="100%" cellpadding="0" cellspacing="2">
147<tr>
148<td class='online-navigation'><a rel="prev" title="7.5.4 Module Objects"
149 href="moduleObjects.html"><img src='../icons/previous.png'
150 border='0' height='32' alt='Previous Page' width='32' /></A></td>
151<td class='online-navigation'><a rel="parent" title="7.5 Other Objects"
152 href="otherObjects.html"><img src='../icons/up.png'
153 border='0' height='32' alt='Up One Level' width='32' /></A></td>
154<td class='online-navigation'><a rel="next" title="7.5.6 Descriptor Objects"
155 href="descriptor-objects.html"><img src='../icons/next.png'
156 border='0' height='32' alt='Next Page' width='32' /></A></td>
157<td align="center" width="100%">Python/C API Reference Manual</td>
158<td class='online-navigation'><a rel="contents" title="Table of Contents"
159 href="contents.html"><img src='../icons/contents.png'
160 border='0' height='32' alt='Contents' width='32' /></A></td>
161<td class='online-navigation'><img src='../icons/blank.png'
162 border='0' height='32' alt='' width='32' /></td>
163<td class='online-navigation'><a rel="index" title="Index"
164 href="genindex.html"><img src='../icons/index.png'
165 border='0' height='32' alt='Index' width='32' /></A></td>
166</tr></table>
167<div class='online-navigation'>
168<b class="navlabel">Previous:</b>
169<a class="sectref" rel="prev" href="moduleObjects.html">7.5.4 Module Objects</A>
170<b class="navlabel">Up:</b>
171<a class="sectref" rel="parent" href="otherObjects.html">7.5 Other Objects</A>
172<b class="navlabel">Next:</b>
173<a class="sectref" rel="next" href="descriptor-objects.html">7.5.6 Descriptor Objects</A>
174</div>
175</div>
176<hr />
177<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
178</DIV>
179<!--End of Navigation Panel-->
180<ADDRESS>
181See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
182</ADDRESS>
183</BODY>
184</HTML>