Is there a reason why True and False are still modifiable in Python 2?

Viewed 336

Built-in constants True and False are unmodifiable in Python 3 since at least 3.3:

The false value of the bool type. Assignments to False are illegal and raise a SyntaxError.

The true value of the bool type. Assignments to True are illegal and raise a SyntaxError.

However, in python 2.7, the code True = 0 executes without any exceptions. It seems these restrictions should have been ported to 2.x long ago, but they haven't.

The only reason I can think of is compatibility with existing code base. Do you know any case when the existing software is deliberately modifying True or False? If not, what other reasons might there be?

2 Answers
Related