summaryrefslogtreecommitdiffstats
path: root/Doc/ref
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-09-19 18:21:25 (GMT)
committerFred Drake <fdrake@acm.org>2000-09-19 18:21:25 (GMT)
commit8d27f898b2a601039859cc12e105f567e5d0e946 (patch)
tree49b41663eb787ce6605c25774cf16eb4f4414229 /Doc/ref
parent1156f623483b1c49c1262b8e28a7ac1279e5ba4e (diff)
downloadcpython-8d27f898b2a601039859cc12e105f567e5d0e946.zip
cpython-8d27f898b2a601039859cc12e105f567e5d0e946.tar.gz
cpython-8d27f898b2a601039859cc12e105f567e5d0e946.tar.bz2
Moshe Zadka <mzadka@geocities.com>:
Document the __contains__() method. (Patch slightly modified by FLD.) This closes SourceForge patch #101387.
Diffstat (limited to 'Doc/ref')
-rw-r--r--Doc/ref/ref3.tex10
1 files changed, 10 insertions, 0 deletions
diff --git a/Doc/ref/ref3.tex b/Doc/ref/ref3.tex
index 1b07296..53e919f 100644
--- a/Doc/ref/ref3.tex
+++ b/Doc/ref/ref3.tex
@@ -1172,6 +1172,16 @@ involving extended slice notation, or in absence of the slice methods,
\method{__getitem__()}, \method{__setitem__()} or \method{__delitem__()} is
called with a slice object as argument.
+The membership test operators (\keyword{in} and \keyword{not in}) are
+normally implemented as iteration loop through the sequence. However,
+sequence objects can supply the following special method with a more
+efficient implementation:
+
+\begin{methoddesc}[sequence object]{__contains__}{self, item}
+Called to implement membership test operators. Should return true if
+\var{item} is in \var{self}, false otherwise.
+\end{methoddesc}
+
\subsection{Emulating numeric types\label{numeric-types}}