How to determine the bool between the strings and ints?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Sep 7 22:15:48 CEST 2007


On Fri, 07 Sep 2007 12:26:46 -0700, Zentrader wrote:

> Looks like a "feature" of isinstance() is to consider both True and 1 as
> booleans, but type() distinguishes between the two.

That's not a "feature", it is just OOP.  `bool` is a subclass of `int`
therefore every `bool` instance is also an instance of `int`.  There's
nothing special about it.

In [57]: issubclass(bool, int)
Out[57]: True

In [58]: bool.__base__
Out[58]: <type 'int'>

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list