[Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

Serhiy Storchaka storchaka at gmail.com
Mon Feb 19 12:40:30 EST 2018


15.02.18 18:27, Guido van Rossum пише:
> A thought just occurred to me. Maybe we should just add a Boolean class 
> to numbers? It's a subclass of Integral, presumably.

Isn't bool a subclass of int only for historical reasons? I think that 
if bool was in Python from the beginning, it would not be an int subclass.

Operations inherited from int like division or bits shift doesn't make 
sense as boolean operations. The only boolean operations are testing for 
truthfulness, `not`, `and` and `or`. But every object in Python supports 
them. The bool class is just a type of constants True and False.



More information about the Python-ideas mailing list