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

Ethan Furman ethan at stoneleaf.us
Thu Apr 7 13:17:57 EDT 2016


On 04/07/2016 09:38 AM, Guido van Rossum wrote:

> Honestly I think that the OP has a point, and I don't think we have to
> bend over backwards to preserve int compatibility. After all str(True)
> != str(1), and surely there are other examples.

I think the str() of a value, while possibly being the most interesting 
piece of information (IntEnum, anyone?), is hardly the most intrinsic.

If we do make this change, besides needing a couple major versions to 
make it happen, will anything else be different?

- no longer subclass int?
- add an "unknown" value?
   - how will indexing work?
   - or any of the other operations?
- don't bother with any of the other mathematical operations?
   - counting True's is not the same as adding True's

I'm not firmly opposed, I just don't see a major issue here -- I've 
needed an Unknown value for more often that I've needed ~True to be False.

--
~Ethan~


More information about the Python-ideas mailing list