PEP 285: Adding a bool type

Erik Max Francis max at alcyone.com
Sat Mar 30 17:18:54 EST 2002


Paul Rubin wrote:

> I don't see much need for it.  There's no need to turn Python into
> Java.
> Python, C, and Lisp have all done fine without bools.  What kinds of
> programming tasks in Python are bools supposed to make easier?

Comparing Python's lack of a Boolean type to C (which _does_ have one in
the latest C99 Standard, so I'll presume you mean C89) and Lisp seems
somewhat unfair, since their conceptions of what is true and false are
much simpler than Python's.  In C, any non-zero value (integral or
floating point) or null pointer is true; in Lisp, any non-nil value is
true.  Lisp even has a special symbol for representing explicit truth:
t.

Python's non-bool concept of truth is much more complicated, as many
things can be false:  0, 0.0, 0-as-rational (when and if that happens),
empty strings, empty lists, empty tuples, empty dictionaries, and --
more importantly -- any class instance that implements the __nonzero__
method to return one of the above values.

I'd say that C and Lisp lacking a Boolean type is in a different
category of language design than Python lacking one.  Truth testing is
so simple in C and Lisp that you can get away with not having one pretty
easily.  I don't think that's the case for Python; Python's lack of a
Boolean data type is one of the few things I think is truly missing.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Nationalism is an infantile sickness.
\__/ Albert Einstein
    Alcyone Systems' Daily Planet / http://www.alcyone.com/planet.html
 A new, virtual planet, every day.



More information about the Python-list mailing list