Re: Why do integers compare equal to booleans?

2018-11-16 Thread Santiago Basulto
> Because Python used not to have a boolean type and used the integers 0 and 1 instead Exactly as Jon says. I wrote a post some time ago with more info about it: https://blog.rmotr.com/those-tricky-python-booleans-2100d5df92c On Fri, Nov 16, 2018 at 12:23 PM duncan smith wrote: > On 16/11/18

RE: Why do integers compare equal to booleans?

2018-11-16 Thread David Raymond
A boolean type didn't come about until version 2.3, and even now they still inherit from integers. Some links for you: https://docs.python.org/3.7/whatsnew/2.3.html#pep-285-a-boolean-type https://docs.python.org/3.7/library/stdtypes.html#boolean-values

Re: Why do integers compare equal to booleans?

2018-11-16 Thread duncan smith
On 16/11/18 14:51, Steve Keller 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? > > $ python3 > Python 3.5.2 (default, Nov 12 2018, 13:43:14) > [GCC 5.4.0 20160609] on linux > Type "help",

Re: Why do integers compare equal to booleans?

2018-11-16 Thread Jon Ribbens
On 2018-11-16, Steve Keller 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