Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This should stop in a type error just like `0 + False` or `1 + "1"`. This code is almost always a programmer error.


Yeah I wish they didn't let you do arithmetic on Boolean with int without explicit conversion. It can be useful, but the explicit conversion isn't a large burden and prevents many errors.


It's for backwards compatibility. Which everyone who complains about 2 vs 3 should understand.

Before bool existed, some folks had a habit of writing `False = 0` and `True = 1` for readability.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: