mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
Added documentation for PyDict_Update() and PyDict_Merge().
This commit is contained in:
parent
e45763a8e6
commit
11ee90289c
1 changed files with 19 additions and 1 deletions
|
|
@ -3782,6 +3782,7 @@ Empties an existing dictionary of all key-value pairs.
|
||||||
\begin{cfuncdesc}{PyObject*}{PyDict_Copy}{PyObject *p}
|
\begin{cfuncdesc}{PyObject*}{PyDict_Copy}{PyObject *p}
|
||||||
Returns a new dictionary that contains the same key-value pairs as p.
|
Returns a new dictionary that contains the same key-value pairs as p.
|
||||||
Empties an existing dictionary of all key-value pairs.
|
Empties an existing dictionary of all key-value pairs.
|
||||||
|
\versionadded{1.6}
|
||||||
\end{cfuncdesc}
|
\end{cfuncdesc}
|
||||||
|
|
||||||
\begin{cfuncdesc}{int}{PyDict_SetItem}{PyObject *p, PyObject *key,
|
\begin{cfuncdesc}{int}{PyDict_SetItem}{PyObject *p, PyObject *key,
|
||||||
|
|
@ -3874,7 +3875,8 @@ while (PyDict_Next(self->dict, &pos, &key, &value)) {
|
||||||
|
|
||||||
The dictionary \var{p} should not be mutated during iteration. It is
|
The dictionary \var{p} should not be mutated during iteration. It is
|
||||||
safe (since Python 2.1) to modify the values of the keys as you
|
safe (since Python 2.1) to modify the values of the keys as you
|
||||||
iterate over the dictionary, for example:
|
iterate over the dictionary, but only so long as the set of keys does
|
||||||
|
not change. For example:
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
PyObject *key, *value;
|
PyObject *key, *value;
|
||||||
|
|
@ -3894,6 +3896,22 @@ while (PyDict_Next(self->dict, &pos, &key, &value)) {
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
\end{cfuncdesc}
|
\end{cfuncdesc}
|
||||||
|
|
||||||
|
\begin{cfuncdesc}{int}{PyDict_Merge}{PyObject *a, PyObject *b, int override}
|
||||||
|
Iterate over dictionary \var{b} adding key-value pairs to dictionary
|
||||||
|
\var{a}. If \var{override} is true, existing pairs in \var{a} will be
|
||||||
|
replaced if a matching key is found in \var{b}, otherwise pairs will
|
||||||
|
only be added if there is not a matching key in \var{a}. Returns
|
||||||
|
\code{0} on success or \code{-1} if an exception was raised.
|
||||||
|
\versionadded{2.2}
|
||||||
|
\end{cfuncdesc}
|
||||||
|
|
||||||
|
\begin{cfuncdesc}{int}{PyDict_Update}{PyObject *a, PyObject *b}
|
||||||
|
This is the same as \code{PyDict_Merge(\var{a}, \var{b}, 1)} in C, or
|
||||||
|
\code{\var{a}.update(\var{b})} in Python. Returns \code{0} on success
|
||||||
|
or \code{-1} if an exception was raised.
|
||||||
|
\versionadded{2.2}
|
||||||
|
\end{cfuncdesc}
|
||||||
|
|
||||||
|
|
||||||
\section{Other Objects \label{otherObjects}}
|
\section{Other Objects \label{otherObjects}}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue