22 ms·
issubclass(bool, int) == True in Python 2. They're not converted to ints silently they are ints.
by DasIch 8y ago
issubclass(bool, int) == True in Python 2. They're not converted to ints silently they are ints.
- cma 8y agoThe point is they shouldn't be. Knuth argues against implicitly treating bool as int in Concrete Mathematics.
- DasIch 8y agoAgreed, however you have to take context into account. Python 2 didn't always have a bool type (granted, already a mistake), before it was introduced int was used instead. Making bool a subclass of int made it possible to use it even in combination with earlier code, which made adopting it trivial. If bool wouldn't be a subclass of int, some projects probably would still be using int instead of bool.