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.
diff --git a/Doc/ref/ref3.tex b/Doc/ref/ref3.tex
index d355b69..2056a6c 100644
--- a/Doc/ref/ref3.tex
+++ b/Doc/ref/ref3.tex
@@ -162,7 +162,7 @@
These represent elements from the mathematical set of whole numbers.
\obindex{integer}
-There are two types of integers:
+There are three types of integers:
\begin{description}
@@ -187,6 +187,17 @@
an infinite string of sign bits extending to the left.
\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
The rules for integer representation are intended to give the most
@@ -222,6 +233,7 @@
\end{description} % Numbers
+
\item[Sequences]
These represent finite ordered sets indexed by non-negative numbers.
The built-in function \function{len()}\bifuncindex{len} returns the
@@ -1074,8 +1086,10 @@
\end{methoddesc}
\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 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
considered true.