[Python-Dev] Making None a keyword (original) (raw)

Guido van Rossum guido@python.org
Fri, 26 Apr 2002 11:44:23 -0400


[Guido] > ... > It needs to add 'None' as an alternative to all other places where > currently NAME occurs.

Fudge. None makes no sense anywhere in, e.g., dottedname: NAME ('.' NAME)* or globalstmt: 'global' NAME (',' NAME)* but I suppose it has to be allowed for in 2.3 anyway else an existing

Yes, that's (alas) the point.

import None.None.None as None

would yield a SyntaxError instead of a warning.

More realistically,

def foo(a, None=None):
    if a is None: ...

I found 4 examples of this in Zope3 alone, and MAL has some too.

Note too that we can't change the generated code at all for 2.3 unless under the control of a new future statement, else existing None-abusing code could break.

A future statement makes no sense for this, so I guess all we can do in 2.3 is warn about use of None in all contexts except in expressions.

This is really too bad -- I wish we could decide to just break code (since it's a clean break) but apparently that's unacceptable to the users.

--Guido van Rossum (home page: http://www.python.org/~guido/)