summaryrefslogtreecommitdiffstats
path: root/Doc/api
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2001-03-16 15:41:29 (GMT)
committerFred Drake <fdrake@acm.org>2001-03-16 15:41:29 (GMT)
commit83e01bf6c84719f8977d1ffd721d75d8eda2ddf8 (patch)
tree42c378ea919e4e21ecbad12c3bd9715549fd2285 /Doc/api
parentcf20d4f5ad9d8871bec9278a4f8e89f065295900 (diff)
downloadcpython-83e01bf6c84719f8977d1ffd721d75d8eda2ddf8.zip
cpython-83e01bf6c84719f8977d1ffd721d75d8eda2ddf8.tar.gz
cpython-83e01bf6c84719f8977d1ffd721d75d8eda2ddf8.tar.bz2
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.
Diffstat (limited to 'Doc/api')
-rw-r--r--Doc/api/api.tex22
1 files changed, 20 insertions, 2 deletions
diff --git a/Doc/api/api.tex b/Doc/api/api.tex
index 7a11660..128b240 100644
--- a/Doc/api/api.tex
+++ b/Doc/api/api.tex
@@ -3293,7 +3293,7 @@ Inserts \var{value} into the dictionary with a key of \var{key}.
raised.
\end{cfuncdesc}
-\begin{cfuncdesc}{int}{PyDict_SetItemString}{PyDictObject *p,
+\begin{cfuncdesc}{int}{PyDict_SetItemString}{PyObject *p,
char *key,
PyObject *val}
Inserts \var{value} into the dictionary using \var{key}
@@ -3348,9 +3348,27 @@ Returns the number of items in the dictionary. This is equivalent to
\samp{len(\var{p})} on a dictionary.\bifuncindex{len}
\end{cfuncdesc}
-\begin{cfuncdesc}{int}{PyDict_Next}{PyDictObject *p, int *ppos,
+\begin{cfuncdesc}{int}{PyDict_Next}{PyObject *p, int *ppos,
PyObject **pkey, PyObject **pvalue}
+Iterate over all key-value pairs in the dictionary \var{p}. The
+\ctype{int} referred to by \var{ppos} must be initialized to \code{0}
+prior to the first call to this function to start the iteration; the
+function returns true for each pair in the dictionary, and false once
+all pairs have been reported. The parameters \var{pkey} and
+\var{pvalue} should either point to \ctype{PyObject*} variables that
+will be filled in with each key and value, respectively, or may be
+\NULL. The dictionary \var{p} must not be mutated during iteration.
+For example:
+\begin{verbatim}
+PyObject *key, *value;
+int pos = 0;
+
+while (PyDict_Next(self->dict, &pos, &key, &value)) {
+ /* do something interesting with the values... */
+ ...
+}
+\end{verbatim}
\end{cfuncdesc}