Numbers and truth values

Szabolcs szhorvat at gmail.com
Sat Apr 28 15:36:19 CEST 2007


Steven D'Aprano wrote:
> 
>>>> 1 == True
> True
>>>> 0 == False
> True
>>>> 2 == True
> False

Oh my goodness! Now I also get 2 != True. I really don't know what 
happened. Most probably this (as a result of mistyping):

> 
>>>> True = 2  # DON'T DO THIS!!!
>>>> 2 == True
> True
> 

But shouldn't Python forbid this? Is it possible to get a warning when 
unintentionally redefining built-in thing?



More information about the Python-list mailing list