[Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.84,1.85

Guido van Rossum gvanrossum@users.sourceforge.net
Wed, 03 Apr 2002 14:41:52 -0800


Update of /cvsroot/python/python/dist/src/Doc/ref
In directory usw-pr-cvs1:/tmp/cvs-serv31419/Doc/ref

Modified Files:
	ref3.tex 
Log Message:
Add the 'bool' type and its values 'False' and 'True', as described in
PEP 285.  Everything described in the PEP is here, and there is even
some documentation.  I had to fix 12 unit tests; all but one of these
were printing Boolean outcomes that changed from 0/1 to False/True.
(The exception is test_unicode.py, which did a type(x) == type(y)
style comparison.  I could've fixed that with a single line using
issubtype(x, type(y)), but instead chose to be explicit about those
places where a bool is expected.

Still to do: perhaps more documentation; change standard library
modules to return False/True from predicates.



Index: ref3.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v
retrieving revision 1.84
retrieving revision 1.85
diff -C2 -d -r1.84 -r1.85
*** ref3.tex	1 Apr 2002 18:53:36 -0000	1.84
--- ref3.tex	3 Apr 2002 22:41:50 -0000	1.85
***************
*** 163,167 ****
  \obindex{integer}
  
! There are two types of integers:
  
  \begin{description}
--- 163,167 ----
  \obindex{integer}
  
! There are three types of integers:
  
  \begin{description}
***************
*** 188,191 ****
--- 188,202 ----
  \obindex{long integer}
  
+ \item[Booleans]
+ These represent the truth values False and True.  The two objects
+ representing the values False and True are the only Boolean objects.
+ The Boolean type is a subtype of plain integers, and Boolean values
+ behave like the values 0 and 1, respectively, in almost all contexts,
+ the exception being that when converted to a string, the strings
+ \code{"False"} or \code{"True"} are returned, respectively.
+ \obindex{Boolean}
+ \ttindex{False}
+ \ttindex{True}
+ 
  \end{description} % Integers
  
***************
*** 223,226 ****
--- 234,238 ----
  \end{description} % Numbers
  
+ 
  \item[Sequences]
  These represent finite ordered sets indexed by non-negative numbers.
***************
*** 1075,1080 ****
  
  \begin{methoddesc}[object]{__nonzero__}{self}
! Called to implement truth value testing; should return \code{0} or
! \code{1}.  When this method is not defined, \method{__len__()} is
  called, if it is defined (see below).  If a class defines neither
  \method{__len__()} nor \method{__nonzero__()}, all its instances are
--- 1087,1094 ----
  
  \begin{methoddesc}[object]{__nonzero__}{self}
! Called to implement truth value testing, and the built-in operation
! \code{bool()}; should return \code{False} or \code{True}, or their
! integer equivalents \code{0} or \code{1}.
! When this method is not defined, \method{__len__()} is
  called, if it is defined (see below).  If a class defines neither
  \method{__len__()} nor \method{__nonzero__()}, all its instances are