7 Apr
2016
7 Apr
'16
9:32 p.m.
Steven D'Aprano <steve@...> writes:
It also breaks a fundamental property of most mathematical relations:
if a == b, then f(a) == f(b)
(assuming f(a) and f(b) are defined for the type of both a and b).
That is currently true for bools:
py> (True == 1) and (~True == ~1) True py> (False==0) and (~False == ~0) True
You want ~b to return `not b`:
py> (True == 1) and (False == ~1) False py> (False==0) and (True == ~0) False
How about the str function ? str(True) != str(1) str(False) != str(0) True == 1 is not a mathematical relation, it is python's history.