isinstance(False, int)

MRAB python at mrabarnett.plus.com
Fri Mar 5 19:30:06 CET 2010


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.



More information about the Python-list mailing list