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 de tipo para objetos iteradores retornados por
PySeqIter_New()
e a forma de um argumento da função embutidaiter()
para os tipos de sequência embutidos.
-
int PySeqIter_Check(PyObject *op)¶
Retorna true se o tipo de op for
PySeqIter_Type
. Esta função sempre é bem-sucedida.
-
PyObject *PySeqIter_New(PyObject *seq)¶
- Retorna valor: Nova referência. Part of the Stable ABI.
Retorna um iterador que funcione com um objeto de sequência geral, seq. A iteração termina quando a sequência levanta
IndexError
para a operação de assinatura.
-
PyTypeObject PyCallIter_Type¶
- Part of the Stable ABI.
Objeto de tipo para objetos iteradores retornados por
PyCallIter_New()
e a forma de dois argumentos da função embutidaiter()
.
-
int PyCallIter_Check(PyObject *op)¶
Retorna true se o tipo de op for
PyCallIter_Type
. Esta função sempre é bem-sucedida.
-
PyObject *PyCallIter_New(PyObject *callable, PyObject *sentinel)¶
- Retorna valor: Nova referência. Part of the Stable ABI.
Retorna um novo iterador. O primeiro parâmetro, callable, pode ser qualquer objeto chamável do Python que possa ser chamado sem parâmetros; cada chamada deve retornar o próximo item na iteração. Quando callable retorna um valor igual a sentinel, a iteração será encerrada.