[Python-checkins] CVS: python/dist/src/Doc/lib liboperator.tex,1.15,1.16

Fred L. Drake python-dev@python.org
Sun, 1 Oct 2000 20:36:22 -0700


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

Modified Files:
	liboperator.tex 
Log Message:

Add documentation and warnings for the isCallable(), isMappingType(),
isNumberType(), and isSequenceType() functions.

This closes SourceForge bug #115789.


Index: liboperator.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/liboperator.tex,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** liboperator.tex	2000/09/17 16:10:25	1.15
--- liboperator.tex	2000/10/02 03:36:18	1.16
***************
*** 160,163 ****
--- 160,213 ----
  \end{funcdesc}
  
+ The \module{operator} also defines a few predicates to test the type
+ of objects.  \strong{Note:}  Be careful not to misinterpret the
+ results of these functions; only \function{isCallable()} has any
+ measure of reliability with instance objects.  For example:
+ 
+ \begin{verbatim}
+ >>> class C:
+ ...     pass
+ ... 
+ >>> import operator
+ >>> o = C()
+ >>> operator.isMappingType(o)
+ 1
+ \end{verbatim}
+ 
+ \begin{funcdesc}{isCallable}{o}
+ \deprecated{2.0}{Use the \function{callable()} built-in function instead.}
+ Returns true if the object \var{o} can be called like a function,
+ otherwise it returns false.  True is returned for functions, bound and
+ unbound methods, class objects, and instance objects which support the
+ \method{__call__()} method.
+ \end{funcdesc}
+ 
+ \begin{funcdesc}{isMappingType}{o}
+ Returns true if the object \var{o} supports the mapping interface.
+ This is true for dictionaries and all instance objects.
+ \strong{Warning:} There is no reliable way to test if an instance
+ supports the complete mapping protocol since the interface itself is
+ ill-defined.  This makes this test less useful than it otherwise might
+ be.
+ \end{funcdesc}
+ 
+ \begin{funcdesc}{isNumberType}{o}
+ Returns true if the object \var{o} represents a number.  This is true
+ for all numeric types implemented in C, and for all instance objects.
+ \strong{Warning:}  There is no reliable way to test if an instance
+ supports the complete numeric interface since the interface itself is
+ ill-defined.  This makes this test less useful than it otherwise might
+ be.
+ \end{funcdesc}
+ 
+ \begin{funcdesc}{isSequenceType}{o}
+ Returns true if the object \var{o} supports the sequence protocol.
+ This returns true for all objects which define sequence methods in C,
+ and for all instance objects.  \strong{Warning:} There is no reliable
+ way to test if an instance supports the complete sequence interface
+ since the interface itself is ill-defined.  This makes this test less
+ useful than it otherwise might be.
+ \end{funcdesc}
+ 
  
  Example: Build a dictionary that maps the ordinals from \code{0} to