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

Guido van Rossum guido@python.org
Sun, 10 Mar 2002 00:53:34 -0500


I've spent an evening hacking.  There's now an experimental
implementation of the PEP on SourceForge:

http://sourceforge.net/tracker/?func=detail&atid=305470&aid=528022&group_id=5470

It including a unittest file, test_bool.py, which checks the promises
made in the PEP, and a little bit of documentation.  (Unfortunately,
because much about new-style classes in 2.2 is not yet documented,
documenting bool as a subclass of int sticks out like a sore
thumb. :-)

With this, about 12 tests fail for me (on Linux); I'll look into these
later.  They appear shallow (mostly doctests dying on True or False
where 1 or 0 was expected).

Note: this patch does not mean that the PEP is accepted -- it just
means that a sample implementation exists in case someone wants to
explore the effects of the PEP on their code.

It should be easy for example to create a variant that makes
str(False) == "0" rather than "False"; if I do that, 4 more test
succeed.  Changing "False" into "false" would be slightly more work,
because it turns out that the names of the truth values occurs
frequently in doc strings (and I updated all the ones I could find
that were affected).

--Guido van Rossum (home page: http://www.python.org/~guido/)