[Python-3000] Add "generalized boolean" as ABC to PEP 3119
David A. Wheeler
dwheeler at dwheeler.com
Tue Oct 16 20:41:14 CEST 2007
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?).
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.
--- David A. Wheeler
More information about the Python-3000