Numbers and truth values

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Sat Apr 28 13:53:47 EDT 2007


On Sat, 28 Apr 2007 15:36:19 +0200, Szabolcs wrote:

>>>>> 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?

Python forbids very few things in comparison to other languages. The
attitude is "We're all adults here". Because Python is such a dynamic
language, it is often hard for the compiler to tell the difference between
something you are doing deliberately and a mistake.

If you're worried about that, google for PyChecker.


-- 
Steven.




More information about the Python-list mailing list