On Fri, 23 Aug 2013 16:38:43 -0700, jeangawron wrote:

> Python allows you set the value of True
> 
>>>> True = 1.3

Only in older versions of Python. This is for historical reasons: True 
and False were added as built-ins relatively late in Python's history 
(2.2, I think) and so there is still old code that legitimately does this 
at the start of a module:

True = 1
False = not True

Hence, making True and False actual keywords could only occur in Python 
3, which was allowed to break backwards compatibility.

None, on the other hand, has always existed in Python. The very oldest 
versions way back in the mists of time allowed you to rebind None:

[steve@ando ~]$ python1.5
Python 1.5.2 (#1, Aug 27 2012, 09:09:18)  [GCC 4.1.2 20080704 (Red Hat 
4.1.2-52)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> None = 3
>>> None
3


but as that was considered a mistake, *and* it was considered unlikely to 
be any code in the wild that legitimately rebinds None, that was made a 
SyntaxError in Python 2.x.

As for why None, True and False are treated differently than built-ins, 
if I remember the reason why, it is because they are considered 
fundamental to the inner workings of Python, unlike mere builtins like 
len, map, etc. and therefore should be protected.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to