[Python-ideas] Changing the meaning of bool.__invert__
greg.ewing at canterbury.ac.nz
Fri Apr 8 02:26:34 EDT 2016
Michael Selik wrote:
> To clarify, the proposal is: ``~True == False`` but every other operation on
> ``True`` remains the same, including ``True * 42 == 42``. Correct?
Seems to me things are fine as they are.
The justification for & and | on bools returning bools
is that the result remains within the domain of bools,
even when they are interpreted as int operations.
But ~ on a bool-interpreted-as-an-int doesn't have
that property, so ~True is more in the realm of
True * 42 in that regard.
More information about the Python-ideas