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

Michael Mitchell epsilonmichael at gmail.com
Wed Jan 21 21:28:40 CET 2015


On Wed, Jan 21, 2015 at 11:11 AM, Guido van Rossum <guido at python.org> wrote:

> So I believe you are saying, suppose I have a function that takes an
> integer argument and then JSON-encodes it and sends it to some server that
> requires a JSON int. Now suppose you are adding type hints to your code,
> and you add ": int" to the parameter under discussion. And now suppose you
> have a faulty caller which calls this function with the argument set to
> True. This program will type-check correctly, because True is a bool which
> is a subclass of int, but it will run incorrectly, because (under this
> assumption) True will be converted to a JSON true value, which the server
> rejects.


This is much better phrased than what I had written, thanks :) I'll be
watching the Github issue.

Thank you to everyone that replied. My impression is that the rationale in
PEP 285 still holds strong.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150121/c5cd496e/attachment-0001.html>


More information about the Python-ideas mailing list