Why do integers compare equal to booleans?
Jon Ribbens
jon+usenet at unequivocal.eu
Fri Nov 16 10:07:43 EST 2018
On 2018-11-16, Steve Keller <keller at no.invalid> wrote:
> Why do the integers 0 and 1 compare equal to the boolean values False
> and True and all other integers to neither of them?
Because Python used not to have a boolean type and used the integers
0 and 1 instead, so when the boolean type was introduced True and
False were made to behave very much like 1 and 0 for backwards
compatibility reasons.
More information about the Python-list
mailing list