diff options
author | Raymond Hettinger <python@rcn.com> | 2003-06-26 19:32:10 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-06-26 19:32:10 (GMT) |
commit | d0cda1dc9fc4c7aa06c4f330d576782ac03b3728 (patch) | |
tree | 0a9204e95e699be750b12b568cbcabac4a02892a /Doc/ref | |
parent | f6fe4eda6e00028c55fee31f53b92d9740e329fa (diff) | |
download | cpython-d0cda1dc9fc4c7aa06c4f330d576782ac03b3728.zip cpython-d0cda1dc9fc4c7aa06c4f330d576782ac03b3728.tar.gz cpython-d0cda1dc9fc4c7aa06c4f330d576782ac03b3728.tar.bz2 |
SF patch #760792: "wo" in "word" now valid but not documented as such
Revised version of a contribution from Gerrit Holl.
Update the docs for the extended behavior of __contains__
Diffstat (limited to 'Doc/ref')
-rw-r--r-- | Doc/ref/ref5.tex | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Doc/ref/ref5.tex b/Doc/ref/ref5.tex index ae856ff..4949d22 100644 --- a/Doc/ref/ref5.tex +++ b/Doc/ref/ref5.tex @@ -913,10 +913,13 @@ only if there exists an index \var{i} such that \code{\var{x} == \var{y}[\var{i}]} is true. For the Unicode and string types, \code{\var{x} in \var{y}} is true if -and only if there exists an index \var{i} such that \code{\var{x} == -\var{y}[\var{i}]} is true. If \code{\var{x}} is not a string or -Unicode object of length \code{1}, a \exception{TypeError} exception -is raised. +and only if \var{x} is a substring of \var{y}. An equivalent test is +\code{y.find(x) != -1}. Note, \var{x} and \var{y} need not be the +same type; consequently, \code{u'ab' in 'abc'} will return \code{True}. +Empty strings are always considered to be a substring of any other string, +so \code{"" in "abc"} will return \code{True}. +\versionchanged[Previously, \var{x} was required to be a string of +length \code{1}]{2.3} For user-defined classes which define the \method{__contains__()} method, \code{\var{x} in \var{y}} is true if and only if |