~bool deprecation

I would say, beyond that, bool is specifically the ints 0 and 1 too. I’ve used that many times to hack string formatters by multiplying the string by a bool. Since it’s totally valid to multiply a string by 0 to mask it out.

Another reasonable example of something I’ve done before that relies on bool being 1/0:

models: list[Model]

errors = len(models) - sum(m.valid() for m in models)

Which would fail if bool wasn’t 1 and 0

4 Likes