3 ms·
This is just a side-effect of bool being a subclass of int and True and False having the values 1 and 0, respectively. It might seem weird or surprising, but i
by mccutchen 16y ago
This is just a side-effect of bool being a subclass of int and True and False having the values 1 and 0, respectively. It might seem weird or surprising, but it's not a problem with Python's type system.
>>> issubclass(bool, int)
True
>>> isinstance(True, int)
True
>>> int(True)
1
>>> int(False)
0
>>> True == 1
True
>>> False == 0
True