[Python-checkins] CVS: python/dist/src/Doc/ref ref5.tex,1.29,1.30

Fred L. Drake python-dev@python.org
Tue, 11 Jul 2000 12:43:50 -0700


Update of /cvsroot/python/python/dist/src/Doc/ref
In directory slayer.i.sourceforge.net:/tmp/cvs-serv31113/ref

Modified Files:
	ref5.tex 
Log Message:

Moshe Zadka <mzadka@geocities.com>:
Update the "in" / "not in" description to accomodate the current use
of the __contains__() discipline.  This patch also incorporates
suggestions from Marc-Andre Lemburg <mal@lemburg.com>, minor markup
revisions from Fred Drake, and some rewording of the first affected
paragraph (also from Fred).

Closes SourceForge patch #100831.


Index: ref5.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v
retrieving revision 1.29
retrieving revision 1.30
diff -C2 -r1.29 -r1.30
*** ref5.tex	2000/04/25 21:09:10	1.29
--- ref5.tex	2000/07/11 19:43:47	1.30
***************
*** 741,752 ****
  \end{itemize}
  
! The operators \keyword{in} and \keyword{not in} test for sequence
! membership: if \var{y} is a sequence, \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}]}.
! \code{\var{x} not in \var{y}} yields the inverse truth value.  The
! exception \exception{TypeError} is raised when \var{y} is not a sequence,
! or when \var{y} is a string and \var{x} is not a string of length
! one.\footnote{The latter restriction is sometimes a nuisance.}
  \opindex{in}
  \opindex{not in}
--- 741,773 ----
  \end{itemize}
  
! The operators \keyword{in} and \keyword{not in} test for set
! membership: every type can define membership in whatever way is
! appropriate.  Traditionally, this interface has been tightly bound
! the sequence interface, which is related in that presence in a sequence
! can be usefully interpreted as membership in a set.
! 
! For the list, tuple types, \code{\var{x} in \var{y}} is true if and only
! if there exists such 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 such an index \var{i} such that
! \code{var{x} == \var{y}[\var{i}]} is true. If \code{\var{x}} is not
! a string of length \code{1} or a unicode object of length \code{1},
! a \exception{TypeError} exception is raised.
! 
! For user-defined classes which define the \method{__contains__()} method,
! \code{\var{x} in \var{y}} is true if and only if
! \code{\var{y}.__contains__(\var{x})} is true.
! 
! For user-defined classes which do not define \method{__contains__()} and
! do define \var{__getitem__}, \code{\var{x} in \var{y}} is true if and only
! if there is a non-negative integer index \var{i} such that
! \code{\var{x} == \var{y}[\var{i}]}, and all lower integer indices
! do not raise \exception{IndexError} exception. (If any other exception
! is raised, it is as if \keyword{in} raised that exception).
! 
! The operator \keyword{not in} is defined to have the inverse true value
! of \keyword{in}.
  \opindex{in}
  \opindex{not in}