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

Patrick K. O'Brien pobrien at orbtech.com
Wed Apr 3 14:25:05 EST 2002


[Guido van Rossum]
>
> I offer the following PEP for review by the community.  If it receives
> a favorable response, it will be implemented in Python 2.3.

Yikes! I've read every single response to this so far. It has been quite
enlightening for me. At the same time, I hope it ends soon. ;-)

At this point I'm +1 on the proposal, but I have a favor to ask. While a lot
of the issues raised have been revealing and provocative, I think the vast
majority are tangential to the real substance of this PEP. I'm having
trouble separating what is important from what is not. Is there any way we
can focus the issue a bit?

Specifically:

It feels like there are too many combinations available in the PEP. (Or
maybe too many questions and options which could result in weird
combinations.) I'd like to see a new version with Guido's latest thoughts.
For example, are we closer to a resolution on the str() and repr() issues?
The only behavior I like is that exhibited by the sample code:

>>> str(True)
'True'
>>> repr(True)
'True'

How about the case of the constants: true, false vs. True, False? I like the
latter, which match None. They would also stand out in the new docstrings
mentioned by Fred.

How about operator.truth()? Has Tim changed his mind at all? Has Guido?

If this PEP were implemented and "all built-in operations that conceptually
return a Boolean" were updated, what verifiable examples of code breakage
would we have?

The issue of dictionary keys has been raised, and is a bit perplexing, but
not overly so, IMO. However, I'd like confirmation that this is indeed the
intended behavior:

>>> d = {}
>>> d[0] = 'First'
>>> d
{0: 'First'}
>>> d[False] = 'Second'
>>> d
{0: 'Second'}
>>> d[0.0] = 'Third'
>>> d
{0: 'Third'}
>>> d[()] = 'Fourth'
>>> d
{0: 'Third', (): 'Fourth'}
>>> d[None] = 'Fifth'
>>> d
{0: 'Third', (): 'Fourth', None: 'Fifth'}

Or are there any situations like this where you would want True and False to
be a bit more like None and a bit less like ints? Meaning True and False
could be dictionary keys separate from 0 and 1.

Other than that, are there any concrete issues that have been raised that
need to be addressed by the PEP? I understand the uneasy feeling felt by
many as I felt it myself. However, I've read all the newsgroup postings and
reread the PEP and I don't feel very queasy any more. I think this PEP is a
step in the right direction. I would hope that clarifying some of the
genuine issues might help to bring about consensus and reduce some of the
rhetoric.

---
Patrick K. O'Brien
Orbtech






More information about the Python-list mailing list