Earlier quoted context omitted.
bools can be silently converted to int. 1 + true is ok, but 1 + "true" throws. Sometimes you do want to do math on bools, but it would avoid a class of errors if they would make you wrap them in 'int(the_boolean_variable)'.
> Sometimes you do want to do math on bools.. Can you provide a concrete example for when this would be useful? I assume you're not talking about binary arithmetic.
sum(x > 3 for x in iterable)
True == 1, False == 0, so this counts how many items in iterable are greater than 3.But I think that's the only non-dirty way I've used it, and if that wasn't possible a trivial count() function could do the job.
If I remember correctly, bool subclasses int mostly for compatibility with pre-existing conventions. People were already defining their own "True = 1" and "False = 0" constants before they became part of the language.