@@ -2,10 +2,8 @@ \section{Built-in Types \label{types}}
22
33The following sections describe the standard types that are built into
44the interpreter. These are the numeric types, sequence types, and
5- several others, including types themselves. There is no explicit
6- Boolean type; use integers instead.
5+ several others, including types themselves.
76\indexii {built-in}{types}
8- \indexii {Boolean}{type}
97
108Some operations are supported by several object types; in particular,
119all objects can be compared, tested for truth value, and converted to
@@ -30,6 +28,9 @@ \subsection{Truth Value Testing \label{truth}}
3028\item \code {None}
3129 \withsubitem {(Built-in object)}{\ttindex {None}}
3230
31+ \item \code {False}
32+ \withsubitem {(Built-in object)}{\ttindex {False}}
33+
3334\item zero of any numeric type, for example, \code {0}, \code {0L},
3435 \code {0.0}, \code {0j}.
3536
@@ -50,11 +51,12 @@ \subsection{Truth Value Testing \label{truth}}
5051\index {true}
5152
5253Operations and built-in functions that have a Boolean result always
53- return \code {0} for false and \code {1} for true, unless otherwise
54- stated. (Important exception: the Boolean operations
55- \samp {or}\opindex {or} and \samp {and}\opindex {and} always return one of
56- their operands.)
57-
54+ return \code {0} or \code {False} for false and \code {1} or \code {True}
55+ for true, unless otherwise stated. (Important exception: the Boolean
56+ operations \samp {or}\opindex {or} and \samp {and}\opindex {and} always
57+ return one of their operands.)
58+ \index {False}
59+ \index {True}
5860
5961\subsection {Boolean Operations \label {boolean } }
6062
@@ -68,7 +70,7 @@ \subsection{Boolean Operations \label{boolean}}
6870 {if \var {x} is false, then \var {x}, else \var {y}}{(1)}
6971 \hline
7072 \lineiii {not \var {x}}
71- {if \var {x} is false, then \code {1 }, else \code {0 }}{(2)}
73+ {if \var {x} is false, then \code {True }, else \code {False }}{(2)}
7274\end {tableiii }
7375\opindex {and}
7476\opindex {or}
@@ -161,15 +163,18 @@ \subsection{Comparisons \label{comparisons}}
161163
162164\subsection {Numeric Types \label {typesnumeric } }
163165
164- There are four numeric types: \dfn {plain integers}, \dfn {long integers},
166+ There are four distinct numeric types: \dfn {plain integers},
167+ \dfn {long integers},
165168\dfn {floating point numbers}, and \dfn {complex numbers}.
169+ In addition, Booleans are a subtype of plain integers.
166170Plain integers (also just called \dfn {integers})
167171are implemented using \ctype {long} in C, which gives them at least 32
168172bits of precision. Long integers have unlimited precision. Floating
169173point numbers are implemented using \ctype {double} in C. All bets on
170174their precision are off unless you happen to know the machine you are
171175working with.
172176\obindex {numeric}
177+ \obindex {Boolean}
173178\obindex {integer}
174179\obindex {long integer}
175180\obindex {floating point}
@@ -1389,6 +1394,22 @@ \subsubsection{The Ellipsis Object \label{bltin-ellipsis-object}}
13891394
13901395It is written as \code {Ellipsis}.
13911396
1397+ \subsubsection {Boolean Values }
1398+
1399+ Boolean values are the two constant objects \code {False} and
1400+ \code {True}. They are used to represent truth values (although other
1401+ values can also be considered false or true). In numeric contexts
1402+ (for example when used as the argument to an arithmetic operator),
1403+ they behave like the integers 0 and 1, respectively. The built-in
1404+ function \function {bool()} can be used to cast any value to a Boolean,
1405+ if the value can be interpreted as a truth value (see section Truth
1406+ Value Testing above).
1407+
1408+ They are written as \code {False} and \code {True}, respectively.
1409+ \index {False}
1410+ \index {True}
1411+ \indexii {Boolean}{values}
1412+
13921413
13931414\subsubsection {Internal Objects \label {typesinternal } }
13941415
0 commit comments