diff Doc/lib/libstdtypes.tex @ 17594:bf94af396b1e legacy-trunk

Implement, test and document "key in dict" and "key not in dict". I know some people don't like this -- if it's really controversial, I'll take it out again. (If it's only Alex Martelli who doesn't like it, that doesn't count as "real controversial" though. :-) That's why this is a separate checkin from the iterators stuff I'm about to check in next.
author Guido van Rossum <guido@python.org>
date Fri, 20 Apr 2001 16:50:40 +0000
parents 68bd96e426e3
children d638e419c304
line wrap: on
line diff
--- a/Doc/lib/libstdtypes.tex	Thu Apr 19 21:55:14 2001 +0000
+++ b/Doc/lib/libstdtypes.tex	Fri Apr 20 16:50:40 2001 +0000
@@ -867,8 +867,14 @@
           {(1)}
   \lineiii{\var{a}.clear()}{remove all items from \code{a}}{}
   \lineiii{\var{a}.copy()}{a (shallow) copy of \code{a}}{}
+  \lineiii{\var{k} \code{in} \var{a}}
+          {\code{1} if \var{a} has a key \var{k}, else \code{0}}
+          {}
+  \lineiii{\var{k} not in \var{a}}
+          {\code{0} if \var{a} has a key \var{k}, else \code{1}}
+          {}
   \lineiii{\var{a}.has_key(\var{k})}
-          {\code{1} if \var{a} has a key \var{k}, else \code{0}}
+          {Equivalent to \var{k} \code{in} \var{a}}
           {}
   \lineiii{\var{a}.items()}
           {a copy of \var{a}'s list of (\var{key}, \var{value}) pairs}
@@ -879,11 +885,11 @@
           {(3)}
   \lineiii{\var{a}.values()}{a copy of \var{a}'s list of values}{(2)}
   \lineiii{\var{a}.get(\var{k}\optional{, \var{x}})}
-          {\code{\var{a}[\var{k}]} if \code{\var{a}.has_key(\var{k})},
+          {\code{\var{a}[\var{k}]} if \code{\var{k} in \var{a}}},
            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})},
+          {\code{\var{a}[\var{k}]} if \code{\var{k} in \var{a}}},
            else \var{x} (also setting it)}
           {(5)}
   \lineiii{\var{a}.popitem()}