Name
PyDict_Next
Synopsis
int PyDict_Next(PyObject*x
,int*pos
,PyObject**k
,PyObject**v
)
Iterates over items in dictionary x
. You
must initialize *
pos
to
0
at the start of the iteration:
PyDict_Next
uses and updates
*
pos
to keep track of
its place. For each successful iteration step, returns
1
; when there are no more items, returns
0
. Updates
*
k
and
*
v
to point to the next
key and value respectively (borrowed references) at each step that
returns 1
. You can pass either
k
or v
as
NULL
if you are not interested in the key or
value. During an iteration, you must not change in any way the set of
x
’s keys, but you can
change x
’s values as long
as the set of keys remains identical.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.