summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-08-08 16:15:49 (GMT)
committerGuido van Rossum <guido@python.org>2000-08-08 16:15:49 (GMT)
commit8141cf5c76a1a47ccacc14aa4594fcc89499799a (patch)
treec2ab3d99cd0eb212319d15e7fa793e7083b5b772 /Doc
parent79c9b17d174903bf42c8dd878093931d7df5cf57 (diff)
downloadcpython-8141cf5c76a1a47ccacc14aa4594fcc89499799a.zip
cpython-8141cf5c76a1a47ccacc14aa4594fcc89499799a.tar.gz
cpython-8141cf5c76a1a47ccacc14aa4594fcc89499799a.tar.bz2
Barry's patch to document the new setdefault() method. Slightly
clarified the summary for default() in the table to indicate the side effect.
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libstdtypes.tex8
1 files changed, 8 insertions, 0 deletions
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index 842b23b..3adfc6e 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -591,6 +591,10 @@ arbitrary objects):
{\code{\var{a}[\var{k}]} if \code{\var{a}.has_key(\var{k})},
else \var{x}}
{(4)}
+ \lineiii{\var{a}.setdefault(\var{k}\optional{, \var{x}})}
+ {\code{\var{a}[\var{k}]} if \code{\var{a}.has_key(\var{k})},
+ else \var{x} (also setting it)}
+ {(5)}
\end{tableiii}
\noindent
@@ -611,6 +615,10 @@ correspond. This allows the creation of \code{(\var{value},
\item[(4)] Never raises an exception if \var{k} is not in the map,
instead it returns \var{x}. \var{x} is optional; when \var{x} is not
provided and \var{k} is not in the map, \code{None} is returned.
+
+\item[(5)] \function{setdefault()} is like \function{get()}, except
+that if \var{k} is missing, \var{x} is both returned and inserted into
+the dictionary as the value of \var{k}.
\end{description}