None, False, True

Skip Montanaro skip at pobox.com
Tue Sep 16 15:27:30 EDT 2003


    John> Dunno why None and not True / False causes a warning, but you can
    John> turn warnings into errors using the warnings framework, I think.

Too much Python code which needs to run on 2.2 or earlier legitimately
defines True and False something like so:

    try:
        True
    except NameError:
        True = (1 == 1)
        False = not True

All that valid code would raise SyntaxWarning if it was enabled for True and
False.  Note that SyntaxWarning is raised at compilation time, not runtime,
so the compiler doesn't know a priori whether the except clause will
execute.

Skip






More information about the Python-list mailing list