This works:
>>> True = False
>>> True
False
>>> True = not False
>>> True
True
but fails if False
has been fiddled with as well. Therefore this is better:
>>> True = not None
as None
cannot be reassigned.
These also evaluate to True
regardless of whether True
has been reassigned to False
, 5
, 'foo'
, None
, etc:
>>> True = True == True # fails if True = float('nan')
>>> True = True is True
>>> True = not True or not not True
>>> True = not not True if True else not True
>>> True = not 0