Reputation: 1379
While running a Python 2.7 interpreter, I assigned False
to True
. Is there a way to reset True
to its original value without restarting the interpreter? (Assume there isn't any user defined explicit reference available to the original True
in the interpreter environment.)
Upvotes: 1
Views: 49
Reputation: 106588
You can get it from the __builtin__
module:
import __builtin__
True = __builtin__.True
so that:
import __builtin__
True = False
print(True)
True = __builtin__.True
print(True)
would output:
False
True
Upvotes: 1
Reputation: 88378
Yes.
True = (1 == 1)
Note:
>>> True = False
>>> True
False
>>> True and True
False
>>> True = (1 == 1)
>>> True
True
>>> True and True
True
Upvotes: 3