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

Patrick K. O'Brien pobrien@orbtech.com
Wed, 3 Apr 2002 17:22:25 -0600

> Guido van Rossum wrote:
> > False and True are numbers [...]
> That's exactly where this falls down.
> Patrick O'Brien wrote:
> > [...] True and False could be dictionary keys separate from 0 and 1.
> Guido van Rossum wrote:
> > No.  That would break backwards compatibility.  False==0, and True==1;
> > everything else follows from that.  (But False is not 0, and True is
> > not 1!)
> Ka-Ping Yee wrote:
> This is a strange distinction to make -- one that is not made in any
> other programming language i have ever encountered.  Of course *i* get
> it and *you* get it -- but it will be so hard to teach this particular
> weirdness that i consider it fatal to the proposal.

This strange distinction seems to be the crux of the controversy surrounding
this PEP. I thought it a bit strange at first too. But the more I think
about it the less it troubles me. In fact, it is starting to feel downright

True and False are singleton instances of a Boolean subclass of the Integer
class. As a subclass, much of, but not all of, their behavior is inherited
from Integer. So False often acts like 0 and True often acts like 1. But not
always. Because they are instances of a subclass. That's what subclassing
allows. This is Object Orientation 101.

I think the concepts truly are no less difficult to understand or explain
than plenty of other aspects of the Python language. The way Boolean is
being implemented may not be what one would expect, and it may not be what
other languages do, and it may take a little getting used to, and it may
upset some people's preconceptions of truth values, but I think if everyone
steps back and looks at this objectively they have to admit that this
"strange distinction" really isn't too terribly strange after all.

There are plenty of Python features that still make my head hurt. This new
Boolean isn't one of them.

Patrick K. O'Brien