Numbers and truth values

Steven D'Aprano steve at
Sun Apr 29 03:00:31 CEST 2007

On Sat, 28 Apr 2007 23:54:01 +0200, Szabolcs wrote:

> But I still think that it is an inconsistency to allow to redefine a 
> _value_ like True or False (not a built-in function that may have been 
> missing in earlier versions). Saying True = 2 is just like saying 3 = 2.

Well, it might seem that way, but it isn't really. It's more like having
built-in names 

One = 1
Zero = 0

(plus some special code so that when you say "print One" it prints
"One" rather than 1) in Python. You wouldn't be surprised to be able to
redefine One = 2 there, would you?

The ability to shadow built-ins is a fact of life in the Python world.
Python has a lot of built-ins, and very few keywords, and that situation
is unlikely to change. As Alex explained, the philosophy is not to slow
the compiler and interpreter down with checks against those sort of
problems directly, but to trust the programmer to call external tools like
pylint and pychecker if they want. It may be that True and False will
(like None before it) be moved from the built-ins category into the
keyword category, but I don't think that's the most pressing problem in


More information about the Python-list mailing list