bool is a subclass of int, so True and False are the integers 1 and 0
In Python, bool is a subclass of int. True is a bool object with the integer value 1, and False is a bool object with the integer value 0. Because bool inherits from int, comparisons and arithmetic treat them as integers. That is why True == 1 is True, and also why True + True equals 2. This is a deliberate design choice to allow booleans to be used in numeric contexts. The trade-off is that it can surprise developers coming from languages where booleans are distinct types. You can check the exact type with type(x) is bool. In most code, this behavior is harmless, but it matters when you use a boolean as a dict key or in a set, because True and 1 collide.
bool is a subclass of int. True and False are the only instances.
True == 1 and False == 0 evaluate to True because of the integer values.
True + True == 2, True * 5 == 5, and sum([True, True]) == 2.
Because hash(True) == hash(1) and they compare equal, True and 1 collide in dicts and sets.
Common mistake: using a boolean as a dict key and being surprised that 1 overwrites True.
Common mistake: assuming type(True) is int; it is bool.
Version note: this has been true since Python 2.3 and is consistent in Python 3.
0-2 years experience
2-5 years experience
5-8 years experience
8+ years experience