이터레이터 객체¶
파이썬은 두 개의 범용 이터레이터 객체를 제공합니다. 첫째, 시퀀스 이터레이터는 __getitem__() 메서드를 지원하는 임의의 시퀀스와 작동합니다. 둘째는 콜러블 객체와 종료 신호(sentinel) 값을 사용하고, 시퀀스의 각 항목에 대해 콜러블을 호출하고, 종료 신호 값이 반환될 때 이터레이션을 종료합니다.
-
PyTypeObject PySeqIter_Type¶
- Part of the 안정 ABI.
PySeqIter_New()와 내장 시퀀스 형에 대한iter()내장 함수의 단일 인자 형식에 의해 반환된 이터레이터 객체에 대한 형 객체.
-
int PySeqIter_Check(PyObject *op)¶
op의 형이
PySeqIter_Type이면 참을 돌려줍니다. 이 함수는 항상 성공합니다.
-
PyObject *PySeqIter_New(PyObject *seq)¶
- 반환값: 새 참조. Part of the 안정 ABI.
일반 시퀀스 객체 seq와 함께 작동하는 이터레이터를 반환합니다. 시퀀스가 서브스크립션 연산에서
IndexError를 일으키면 이터레이션이 끝납니다.
-
PyTypeObject PyCallIter_Type¶
- Part of the 안정 ABI.
PyCallIter_New()와iter()내장 함수의 두 인자 형식에 의해 반환된 이터레이터 객체에 대한 형 객체.
-
int PyCallIter_Check(PyObject *op)¶
op의 형이
PyCallIter_Type이면 참을 돌려줍니다. 이 함수는 항상 성공합니다.
-
PyObject *PyCallIter_New(PyObject *callable, PyObject *sentinel)¶
- 반환값: 새 참조. Part of the 안정 ABI.
새로운 이터레이터를 돌려줍니다. 첫 번째 매개 변수 callable은 매개 변수 없이 호출할 수 있는 모든 파이썬 콜러블 객체일 수 있습니다; 각 호출은 이터레이션의 다음 항목을 반환해야 합니다. callable이 sentinel와 같은 값을 반환하면 이터레이션이 종료됩니다.
Other Iterator Objects¶
-
PyTypeObject PyByteArrayIter_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyBytesIter_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyListIter_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyListRevIter_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PySetIter_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyTupleIter_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyRangeIter_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyLongRangeIter_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyDictIterKey_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyDictRevIterKey_Type¶
- Part of the 안정 ABI 버전 3.8 이후로.
-
PyTypeObject PyDictIterValue_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyDictRevIterValue_Type¶
- Part of the 안정 ABI 버전 3.8 이후로.
-
PyTypeObject PyDictIterItem_Type¶
- Part of the 안정 ABI.
-
PyTypeObject PyDictRevIterItem_Type¶
- Part of the 안정 ABI 버전 3.8 이후로.
Type objects for iterators of various built-in objects.
Do not create instances of these directly; prefer calling
PyObject_GetIter()instead.Note that there is no guarantee that a given built-in type uses a given iterator type. For example, iterating over
rangewill use one of two iterator types depending on the size of the range. Other types may start using a similar scheme in the future, without warning.