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

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jan 21 23:18:35 CET 2015


Guido van Rossum wrote:
> 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 could be regarded as just one of the many things
that static type checking can't catch, and needs to be
checked at run time.

However, with something like the exactly() function
suggested earlier, the required type could be described
statically.

-- 
Greg


More information about the Python-ideas mailing list