diff options
author | Barry Warsaw <barry@python.org> | 1997-10-06 17:50:48 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1997-10-06 17:50:48 (GMT) |
commit | dc0f00ad0342a81052dc2e96ed493391ea7b95ec (patch) | |
tree | f4206eeb3b233ab98cdbe8d039a76659ce7c76c1 /Doc | |
parent | fc3e61cd2816274e49dfd42ddc29b38d3118bd21 (diff) | |
download | cpython-dc0f00ad0342a81052dc2e96ed493391ea7b95ec.zip cpython-dc0f00ad0342a81052dc2e96ed493391ea7b95ec.tar.gz cpython-dc0f00ad0342a81052dc2e96ed493391ea7b95ec.tar.bz2 |
Document the mapping object's new get() method.
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/lib/libtypes.tex | 5 | ||||
-rw-r--r-- | Doc/libtypes.tex | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/Doc/lib/libtypes.tex b/Doc/lib/libtypes.tex index e040c3a..029da07 100644 --- a/Doc/lib/libtypes.tex +++ b/Doc/lib/libtypes.tex @@ -528,6 +528,7 @@ mapping, \var{k} is a key and \var{x} is an arbitrary object): \lineiii{\var{a}.keys()}{a copy of \var{a}'s list of keys}{(2)} \lineiii{\var{a}.update(b)}{\code{for k, v in b.items(): a[k] = v}}{(3)} \lineiii{\var{a}.values()}{a copy of \var{a}'s list of values}{(2)} + \lineiii{\var{a}.get(k, f)}{the item of \var{a} with key \var{k}}{(4)} \end{tableiii} \indexiii{operations on}{mapping}{types} \indexiii{operations on}{dictionary}{type} @@ -545,6 +546,10 @@ Notes: \item[(2)] Keys and values are listed in random order. \item[(3)] \code{b} must be of the same type as \code{a}. + +\item[(4)] Never raises an exception if \var{k} is not in the map, +instead it returns \var{f}. \var{f} is optional, when not provided +and \var{k} is not in the map, \code{None} is returned. \end{description} \subsection{Other Built-in Types} diff --git a/Doc/libtypes.tex b/Doc/libtypes.tex index e040c3a..029da07 100644 --- a/Doc/libtypes.tex +++ b/Doc/libtypes.tex @@ -528,6 +528,7 @@ mapping, \var{k} is a key and \var{x} is an arbitrary object): \lineiii{\var{a}.keys()}{a copy of \var{a}'s list of keys}{(2)} \lineiii{\var{a}.update(b)}{\code{for k, v in b.items(): a[k] = v}}{(3)} \lineiii{\var{a}.values()}{a copy of \var{a}'s list of values}{(2)} + \lineiii{\var{a}.get(k, f)}{the item of \var{a} with key \var{k}}{(4)} \end{tableiii} \indexiii{operations on}{mapping}{types} \indexiii{operations on}{dictionary}{type} @@ -545,6 +546,10 @@ Notes: \item[(2)] Keys and values are listed in random order. \item[(3)] \code{b} must be of the same type as \code{a}. + +\item[(4)] Never raises an exception if \var{k} is not in the map, +instead it returns \var{f}. \var{f} is optional, when not provided +and \var{k} is not in the map, \code{None} is returned. \end{description} \subsection{Other Built-in Types} |