Mercurial > cpython-lru_cache-weakref
annotate Doc/c-api/iterator.rst @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | 74ff71b2f53d |
| children |
| rev | line source |
|---|---|
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
1 .. highlightlang:: c |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
3 .. _iterator-objects: |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
4 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
5 Iterator Objects |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
6 ---------------- |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
7 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
8 Python provides two general-purpose iterator objects. The first, a sequence |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
9 iterator, works with an arbitrary sequence supporting the :meth:`__getitem__` |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
10 method. The second works with a callable object and a sentinel value, calling |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
11 the callable for each item in the sequence, and ending the iteration when the |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
12 sentinel value is returned. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
13 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
14 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
15 .. c:var:: PyTypeObject PySeqIter_Type |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
16 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
17 Type object for iterator objects returned by :c:func:`PySeqIter_New` and the |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
18 one-argument form of the :func:`iter` built-in function for built-in sequence |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
19 types. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
20 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
21 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
22 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
23 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
24 .. c:function:: int PySeqIter_Check(op) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
25 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
26 Return true if the type of *op* is :c:data:`PySeqIter_Type`. |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
27 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
28 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
29 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
30 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
31 .. c:function:: PyObject* PySeqIter_New(PyObject *seq) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
32 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
33 Return an iterator that works with a general sequence object, *seq*. The |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
34 iteration ends when the sequence raises :exc:`IndexError` for the subscripting |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
35 operation. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
36 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
37 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
38 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
39 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
40 .. c:var:: PyTypeObject PyCallIter_Type |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
41 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
42 Type object for iterator objects returned by :c:func:`PyCallIter_New` and the |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
43 two-argument form of the :func:`iter` built-in function. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
44 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
45 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
46 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
47 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
48 .. c:function:: int PyCallIter_Check(op) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
49 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
50 Return true if the type of *op* is :c:data:`PyCallIter_Type`. |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
51 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
52 .. versionadded:: 2.2 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
53 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
54 |
|
74395
74ff71b2f53d
update to new C roles and directives
Sandro Tosi <sandro.tosi@gmail.com>
parents:
44796
diff
changeset
|
55 .. c:function:: PyObject* PyCallIter_New(PyObject *callable, PyObject *sentinel) |
|
44796
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
56 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
57 Return a new iterator. The first parameter, *callable*, can be any Python |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
58 callable object that can be called with no parameters; each call to it should |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
59 return the next item in the iteration. When *callable* returns a value equal to |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
60 *sentinel*, the iteration will be terminated. |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
61 |
|
13dc65fe8599
Split the monstrous C API manual files in smaller parts.
Georg Brandl <georg@python.org>
parents:
diff
changeset
|
62 .. versionadded:: 2.2 |
