[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: isinstance(False, int

Terry Reedy

3/5/2010 9:28:00 PM

On 3/5/2010 1:30 PM, MRAB wrote:
> mk wrote:
>> >>> isinstance(False, int)
>> True
>> >>>
>> >>> isinstance(True, int)
>> True
>>
>> Huh?
>>
>> >>>
>> >>> issubclass(bool, int)
>> True
>>
>> Huh?!
>>
> Python didn't have Booleans originally, 0 and 1 were used instead. When
> bool was introduced it was made a subclass of int so that existing code
> wouldn't break.

And because it is useful to make it so.

Terry Jan Reedy