Re: Why is 'None' not assignable but 'True'/'False' are?



Rodney Maxwell <rodney.maxwell@xxxxxxxxx> wrote:

> In Python 2.4.1:
>
> >>> None = 99
> SyntaxError: assignment to None
> >>> True = 99
> >>> False = 99
> >>> True == False
> True
> -----------------------
> So why is 'None' special?

A legacy/backwards compatibility issue: None has been there 'forever',
so that no sensible code ever had any business assigning to it; but
'False' and 'True' were introduced just a few years ago, and it was
important to not break sensible existing code doing something like

True = 1
False = 0

at the very start. In Python 3.0, when backwards compatibilities can be
introduced, True and False will become keywords (as will None); see
<http://www.python.org/peps/pep-3000.html>.


Alex
.



Relevant Pages

  • Re: Why is None not assignable but True/False are?
    ... >> SyntaxError: assignment to None ... > A legacy/backwards compatibility issue: ... In Python 3.0, ... I don't think it would be a good idea to make them keywords. ...
    (comp.lang.python)
  • Re: why cannot assign to function call
    ... as in Python, Java, REALbasic, .NET, etc. ... Pointers are passed and assigned by value, ... If you simply use the name, you get by-value semantics. ... Python's assignment semantics, and further appear ...
    (comp.lang.python)
  • Re: By value or by reference?
    ... >> just like Python never does. ... ...which in turn depends, also, on what assignment statements mean *in ... once you call foo, in each language, it's just as if there had been ... registers and addressability only of memory, not of registers, and ...
    (comp.lang.python)
  • Re: Is python very slow compared to C
    ... Yes, but quite similar to assignment in Java, which is apparently the ... most widely taught language nowadays. ... copy) and SET (assignment by reference, like Java and Python). ... If Cobol's key underlying concepts had proved satisfactory to the needs ...
    (comp.lang.python)
  • Re: Java or C++?
    ... Plus there are several toolkits and existing libraries available for Python. ... Take a string object for example. ... a copy constructor or assignment operator can be implemented when using C++. ... And if you want more control you can implement the default and copy constructors, destructor, and assignment operator, and tell them to do what you want. ...
    (comp.lang.python)