When implementing a board game, a board cell can be in one of the three different possible states available: True (cell occupied by first player), False (cell occupied by second player) or None (cell is empty).
My question is that:
Why does
not(True) == None
return True
whereas that it should actually return False
?
And why does
not(False) == None
return True
whereas that it should actually return False
?
Could this be a possible bug in Python that should be reported up to the developers, whom from among them, as soon as possible?
not
is not a function, and not(True)
is not a function call.
not(True) == None
is parsed as not (True == None)
, because not
has lower precedence than ==
.
Please keep Python's operator precedence in mind when writing expressions, and don't treat things like functions if they're not functions.