[Python-3000] Add "generalized boolean" as ABC to PEP 3119
Brett Cannon
brett at python.org
Tue Oct 16 23:03:51 CEST 2007
On 10/16/07, David A. Wheeler <dwheeler at dwheeler.com> wrote:
> Hi, I'm a Python user who likes much in the upcoming Python 3000. I wish you well! I have a few comments, though, that I hope are constructive. Guido asked me to repost them to this mailing list for discussion. I'll send my different comments as separate messages, so that they can be easily discussed separately. So...
>
> In PEP 3119 (Abstract Base Classes): I suggest adding an ABC for a "generalized bool" (perhaps name it Gbool?).
That just makes me think it is a Google product. I would say Boolean
is a fine name since the type is named bool, but that might be too
close of a name.
>
> Any class defining __bool__ (formerly __nonzero__), or one implementing Sized (which implement __len__), would be a generalized boolean. (Well, unless __len__ is no longer auto-called if there's no __bool__; if there's no auto-call, then I think just __bool__ would be checked, similar to how Sized works). All numbers and collections are generalized bools, obviously; many user-created classes will NOT be generalized bools. Many functions accept generalized bools, not strictly bools, and it'd be very nice to be able to explicitly _denote_ that in a standard way.
Seems fine by me.
-Brett
More information about the Python-3000
mailing list