22 Dec
2020
22 Dec
'20
9 a.m.
21.12.20 10:11, Paul Bryan пише:
Wouldn't that still work if bool's __int__ returns 1?
Implementing `__index__` would solve 90% of all problems with non-int booleans. But not the example provided by David (it requires `__add__`). And there may be more specific cases when you need to make arithmetic or bit operations with booleans or sort them. In result you would need to implement all method inherited from int in new bool. And what is the difference?