Can someone clarify the logic behind these assignment statements.
>>> True
True
>>> True = False
>>> True
False
>>> True = True
>>> True
False
>>> a = True
>>> if a:
... print "a is True"
... else:
... print "a is False"
...
a is False
According to the manual, the only two instances of class bool is True
and False
.
Help on bool object:
True = class bool(int)
| bool(x) -> bool
|
| Returns True when the argument x is true, False otherwise.
| The builtins True and False are the only two instances of the class bool.
| The class bool is a subclass of the class int, and cannot be subclassed.
|
| Method resolution order:
| bool
| int
| object
So am I overriding the default instance? And if so, why does python does not assign True
to is default instance in the below assignment? How can I assign the default python True
in the below statement?
>>> True = False
>>> True
False
>>> True = True
>>> True
False #why?
Thanks in advance for any help!!!