[Python-ideas] Changing the meaning of bool.__invert__

Guido van Rossum guido at python.org
Thu Apr 7 14:08:38 EDT 2016


On Thu, Apr 7, 2016 at 10:39 AM, Michael Selik <mike at selik.org> wrote:
>
>> On Apr 7, 2016, at 6:23 PM, Guido van Rossum <guido at python.org> wrote:
>> Nothing else is on the table. Seriously. Stop hijacking the thread.
>
> To clarify, the proposal is: ``~True == False`` but every other operation on ``True`` remains the same, including ``True * 42 == 42``. Correct?

Yes. To be more precise, there are some "arithmetic" operations (+, -,
*, /, **) and they all treat bools as ints and always return ints;
there are also some "bitwise" operations (&, |, ^, ~) and they should
all treat bools as bools and return a bool. Currently the only
exception to this idea is that ~ returns an int, so the proposal is to
fix that. (There are also some "boolean" operations (and, or, not) and
they are also unchanged.)

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list