On 10/16/07, David A. Wheeler <[EMAIL PROTECTED]> 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?).
>
> 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.

This sounds misguided to me. While it is true that some types can
never be false, they can still be useful as a truth value: e.g. a
parameter could be either a Widget object (assuming Widgets are never
false) or None. This is used pretty commonly.

So there is absolutely nothing to test for in the type of an object --
*every* object is usable as a "generalized boolean". It therefore
becomes purely a matter of argument annotation, an area which is
explicitly left open for experimentation by PEP 3107.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to