Why were True and False changed to keywords in Python 3

Possibly because Python 2.6 not only allowed True = False but also allowed you to say funny things like:

__builtin__.True = False

which would reset True to False for the entire process. It can lead to really funny things happening:

>>> import __builtin__
>>> __builtin__.True = False
>>> True
False
>>> False
False
>>> __builtin__.False = True
>>> True
False
>>> False
False

EDIT: As pointed out by Mike, the Python wiki also states the following under Core Language Changes:

  • Make True and False keywords.
    • Reason: make assignment to them impossible.

Leave a Comment