[Python-ideas] Should bool continue to inherit from int?

Michael Mitchell epsilonmichael at gmail.com
Wed Jan 21 12:32:49 CET 2015

PEP 285 <http://legacy.python.org/dev/peps/pep-0285> provides some
justification for why arithmetic operations should be valid on bools and
why bool should inherit from int (see points (4) and (6) respectively).
Since it's been 12 years (it's possible this has been brought up again
between now and then), I thought it could be worthwhile to take another

I am mostly interested in a resurveying of the questions:
1) Would it still be very inconvenient to implement bools separately from
2) Do most Python users still agree that arithmetic operations should be
supported on booleans?

Follow-up thought:
Something I noticed is that with PEP 484
<https://www.python.org/dev/peps/pep-0484/> (Type Hints) specified as is,
there would be no way to statically verify that a function will only
operate on ints and not bools. An example would be a function that can only
operate on integer values in a JSON dict created by the builtin `json`
module (using the default decoder) cannot exist, as that function could
operate on the boolean values of the dict.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150121/b6f5d272/attachment.html>

More information about the Python-ideas mailing list