4 ms·
Booleans are integers in Python too: >>> True + 0 1
by TorKlingberg 12y ago
Booleans are integers in Python too:
>>> True + 0
1
- AlexandrB 12y agoIt would be more correct to say that the "bool" type implements an "__int__" method for conversion to an integer, but the types are actually distinct: >>> type(True) <type 'bool'> >>> type(1) <type 'int'> Edit: oops, I'm wrong. "bool" also inherits from "int": http://stackoverflow.com/questions/8169001/why-is-bool-a-subclass-of-int http://stackoverflow.com/questions/8169001/why-is-bool-a-sub...