diff Doc/lib/libstdtypes.tex @ 13894:77b9e041b595 legacy-trunk

Barry's patch to document the new setdefault() method. Slightly clarified the summary for default() in the table to indicate the side effect.
author Guido van Rossum <guido@python.org>
date Tue, 08 Aug 2000 16:15:49 +0000
parents e20fe0052680
children 4d14eef8ea07
line wrap: on
line diff
--- a/Doc/lib/libstdtypes.tex	Tue Aug 08 16:13:23 2000 +0000
+++ b/Doc/lib/libstdtypes.tex	Tue Aug 08 16:15:49 2000 +0000
@@ -591,6 +591,10 @@
           {\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 @@
 \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}