isinstance(False, int)

Terry Reedy tjreedy at udel.edu
Fri Mar 5 16:51:25 EST 2010


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.

Terry Jan Reedy






More information about the Python-list mailing list