[Python-Dev] Re: PEP 285: Adding a bool type

Fredrik Lundh fredrik@pythonware.com
Wed, 3 Apr 2002 19:03:24 +0200

andrew wrote:
> Fredrik> if you study real python code, you'll find that there is.
> I mean that the language doesn't prefer a single way,
> as opposed to programmers' conventions.

it's more than just a convention -- built-in functions and operators
always return 0 for false and 1 for true whenever they need to in-
vent a boolean value.  this is documented in the language reference.

(and if you look inside, there's something called Py_False that's an
integer zero, and something called Py_True that is an integer one).

this is also true for the standard library, and lots of major extensions.

also note that the PEP says "The bool type would be a straightforward
subtype (in C) of the int type, and the values False and True would
behave like 0 and 1 in most respects".  Guido didn't pick those values
out of thin air...