22.12.20 02:52, Christopher Barker пише:
On Mon, Dec 21, 2020 at 3:37 PM Greg Ewing <firstname.lastname@example.org mailto:email@example.com> wrote: > However, that ship has sailed. I think it would have been minimally > disruptive when True and False were first introduced,
It would have been just as disruptive back then -- that's the reason bool was made a subclass of int in the first place.
I know why, but I'm not so sure -- no one was using a built in True or False as an integer, because they didn't exist. I suppose folks were using the results of, e.g. `a == b` as an integer, but how often? Where else is an explicit True or False returned by Python itself?
Every time you use a builtin function which has semantically boolean parameter. They are usually converted to C using PyArg_Parse("i").
['a', 'b', 'c']
['c', 'b', 'a']
Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'list' object cannot be interpreted as an integer
There are tons of such parameters in the stdlib (it can be changed) and zillions of them in third-party extensions which will be broken with non-int booleans.