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

Ethan Furman ethan at stoneleaf.us
Thu Apr 7 12:25:52 EDT 2016


On 04/07/2016 09:00 AM, Joseph Martinot-Lagarde wrote:
> Ethan Furman writes:
>
>>> --> ~False
>>> -1
>>>   --> ~True
>>> -2
>>
>> No.  bool is a subclass of int, and changing that now would be a serious
>> breach of backward-compatibility, not to mention breaking existing code
>> for no good reason.
>
> I get that "technically" it would be a backward incompatible change, but any
> code that relies on `~True == -2` has other problems than backward
> compatibility.

Really?  Code that relies on correct behavior (~1 == -2) has problems? 
Well, it may, but that's not it.

--
~Ethan~



More information about the Python-ideas mailing list