True/False

Skip Montanaro skip at pobox.com
Wed Apr 23 15:27:27 CEST 2003


    Python 2.3a2+ (#2, Mar 21 2003, 22:13:05) 
    [GCC 3.2.3 20030316 (Debian prerelease)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> try:
    ...     None
    ... except NameError:
    ...     None = 0
    ... 
    <stdin>:4: SyntaxWarning: assignment to None

What does this have to do with conditional assignment to True and False?
Sure, in 2.3 you get a SyntaxWarning when assigning to None.  So don't do
that.  None has been around for a good long time (probably since the Big
Bang or close enough to it that our crude atomic clocks can't measure
precisely when it was added), while True and False are recent inventions.
Assigning to True or False today doesn't produce a SyntaxWarning, and given
that it's rather common to define them in programs, it's likely that it
won't for a long time.  On the other hand, Guido would like to eventually
make None a keyword, so a SyntaxWarning now makes sense.

Skip





More information about the Python-list mailing list