Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 83e01bf

Browse files
committed
Finally fill in the documentation for the PyDict_Next() function. It is
different enough to actually require an explanation. ;-) Fix a couple of PyDictObject* types that should be PyObject* types.
1 parent cf20d4f commit 83e01bf

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

Doc/api/api.tex

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,7 +3293,7 @@ \subsection{Dictionary Objects \label{dictObjects}}
32933293
raised.
32943294
\end{cfuncdesc}
32953295

3296-
\begin{cfuncdesc}{int}{PyDict_SetItemString}{PyDictObject *p,
3296+
\begin{cfuncdesc}{int}{PyDict_SetItemString}{PyObject *p,
32973297
char *key,
32983298
PyObject *val}
32993299
Inserts \var{value} into the dictionary using \var{key}
@@ -3348,9 +3348,27 @@ \subsection{Dictionary Objects \label{dictObjects}}
33483348
\samp{len(\var{p})} on a dictionary.\bifuncindex{len}
33493349
\end{cfuncdesc}
33503350

3351-
\begin{cfuncdesc}{int}{PyDict_Next}{PyDictObject *p, int *ppos,
3351+
\begin{cfuncdesc}{int}{PyDict_Next}{PyObject *p, int *ppos,
33523352
PyObject **pkey, PyObject **pvalue}
3353+
Iterate over all key-value pairs in the dictionary \var{p}. The
3354+
\ctype{int} referred to by \var{ppos} must be initialized to \code{0}
3355+
prior to the first call to this function to start the iteration; the
3356+
function returns true for each pair in the dictionary, and false once
3357+
all pairs have been reported. The parameters \var{pkey} and
3358+
\var{pvalue} should either point to \ctype{PyObject*} variables that
3359+
will be filled in with each key and value, respectively, or may be
3360+
\NULL. The dictionary \var{p} must not be mutated during iteration.
3361+
For example:
33533362

3363+
\begin{verbatim}
3364+
PyObject *key, *value;
3365+
int pos = 0;
3366+
3367+
while (PyDict_Next(self->dict, &pos, &key, &value)) {
3368+
/* do something interesting with the values... */
3369+
...
3370+
}
3371+
\end{verbatim}
33543372
\end{cfuncdesc}
33553373

33563374

0 commit comments

Comments
 (0)