PEP 285: Adding a bool type

John Roth johnroth at ameritech.net
Wed Apr 3 06:57:52 EST 2002


"David Ascher" <DavidA at ActiveState.com> wrote in message
news:mailman.1017799668.13959.python-list at python.org...
> Guido van Rossum wrote:
> >
> > Alex Martelli wrote:
> > > I _have_ seen old-time Fortranites rant quite convincingly against
that
> > > useless, newfangled LOGICAL stuff.
> >
> > And that is exactly what many of the responses in this thread
> > (including Laura's over-long FUD piece) sound like.
> >
> > I'm reading (at least skimming) everything, but the more I read the
> > reactions, the more I believe that this is just the response I have
to
> > expect for *every* change to the language I propose, and the more
I'm
> > tempted to follow my gut instincts.
>
> IIRC, there wasn't nearly this much heat in the discussion over the
> long/int unification or the type/class unification proposals, even
> though the latter especially was much more complicated, ambitious, and
> compatibility-challenging.

Well, long / int unification was pretty obviously healing a wart, and I
doubt if very many people understood the stakes in the type/class
unification proposal. I know I didn't, or I'd have very vocally
asked for it to be postponed to Python 3000!

In fact, at this point I'd like everything substantive to be defered
to Python 3000, and get started on that right away. I've got a
few suggestions...

> This reminds me of the old saying about academic politics: "the
smaller
> the stakes, the more vicious the fights".

I don't think that's the case here. This proposal opens up a whole
can of worms involving the concept of 'truth', that is, what the
conditional and logical operators see as 'true' or 'false'.

In current Python, truth is whatever an object says it is, using either
the __nonzero__ or the __len__ magic methods. Defining 0 to be
false runs into problems anywhere you have a function that indexes
from zero, and also can return 'not found.' It also makes no sense
for the return from the cmp() function, and I suspect that I could
find other examples if I looked.

Defining empty sequence objects to be false is sometimes what
you want, and sometimes not.

Consequently, I think of it (0 and  1 as false and true) as a
hack carried over from C and similar languages.

John Roth





More information about the Python-list mailing list