Name
bool — Python 2.2 and later
Synopsis
bool(x
)
Returns 0
, also known as False
,
if argument x
evaluates as false; returns
1
, also known as True
, if
argument x
evaluates as true. See also
Section 4.2.6 in Chapter 4. In Python 2.3, bool
becomes a type (a subclass of int
), and built-in
names False
and True
refer to
the only two instances of type bool
. They are
still numbers with values of 0
and
1
respectively, but str(True)
becomes 'True
', and str(False)
becomes 'False
', while in Python 2.2 the
corresponding strings are '0
' and
'1
' respectively.
Get Python in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.