isinstance(False, int)

Chris Rebert clp2 at rebertia.com
Fri Mar 5 19:18:29 EST 2010


On Fri, Mar 5, 2010 at 1:51 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 3/5/2010 1:54 PM, Jean-Michel Pichavant wrote:
>> Steven D'Aprano wrote:
>
>> Despite there are good reasons for bool to be int, the newcomer 'wtf'
>> reaction at first glance is legitimate.
>> Starting python from scratch, booleans would have not been a subclass of
>> int (just guessing though), 'cause it makes no sense from a design POV.
>
> You are just guessing. I would argue for what we have. An example of its
> usefulness:
>
>>>> scores =[True, False, True, True, False]
>>>> score = sum(scores)
>>>> score
> 3
>
> Bools are also usefully used as sequence indexes.

Arguably, these sorts of uses only require bool to be /convertible/ to
int, not to necessarily be a /subclass/ of int.

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list