Objetos iteradores

Python provides two general-purpose iterator objects. The first, a sequence iterator, works with an arbitrary sequence supporting the __getitem__() method. The second works with a callable object and a sentinel value, calling the callable for each item in the sequence, and ending the iteration when the sentinel value is returned.

PyTypeObject PySeqIter_Type
Part of the Stable ABI.

Objeto tipo para objetos iteradores retornados por PySeqIter_New() y la forma de un argumento de la función incorporada iter() para los tipos de secuencia incorporados.

int PySeqIter_Check(PyObject *op)

Retorna verdadero si el tipo de op es PySeqIter_Type. Esta función siempre finaliza con éxito.

PyObject *PySeqIter_New(PyObject *seq)
Return value: New reference. Part of the Stable ABI.

Retorna un iterador que funciona con un objeto de secuencia general, seq. La iteración termina cuando la secuencia lanza IndexError para la operación de suscripción.

PyTypeObject PyCallIter_Type
Part of the Stable ABI.

Objeto tipo para los objetos iteradores retornados por PyCallIter_New() y la forma de dos argumentos de la función incorporada iter().

int PyCallIter_Check(PyObject *op)

Retorna verdadero si el tipo de op es PyCallIter_Type. Esta función siempre finaliza con éxito.

PyObject *PyCallIter_New(PyObject *callable, PyObject *sentinel)
Return value: New reference. Part of the Stable ABI.

Retorna un nuevo iterador. El primer parámetro, callable, puede ser cualquier objeto invocable de Python que se pueda invocar sin parámetros; cada llamada debe retornar el siguiente elemento en la iteración. Cuando callable retorna un valor igual a sentinel, la iteración finalizará.