First Mystery of Strings:
How come bool('foo')
returns True
?
if
'foo' == True
returnsFalse
'foo' == False
returnsFalse
'foo' is True
returnsFalse
'foo' is False
returnsFalse
Second Mystery of Integers:
How come bool(5)
returns True
?
if
5 == True
returnsFalse
5 == False
returnsFalse
5 is True
returnsFalse
5 is False
returnsFalse
Third Mystery of Zeros:
How come bool(0)
returns False
?
if
0 == True
returnsFalse
0 == False
returnsTrue
<-- Special Case
0 is True
returnsFalse
0 is False
returnsFalse
I am aware of some of the truthiness of Python, however, this all seems a bit mysterious. Someone mind shedding some light on this?