Numbers and truth values

Szabolcs szhorvat at gmail.com
Sat Apr 28 09:36:19 EDT 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