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

Ian Kelly ian.g.kelly at gmail.com
Sat Apr 9 10:28:10 EDT 2016

On Sat, Apr 9, 2016 at 2:07 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> On 4/8/2016 11:42 AM, Guido van Rossum wrote:
>> DeprecationWarning every time you use ~ on a bool?
> A DeprecationWarning should only be in the initial version of
> bool.__invert__, which initially would return int.__invert__ after issuing
> the warning that we plan to change the meaning.

It seems unusual to deprecate something without also providing a means
of using the new thing in the same release. "Don't use this feature
because we're going to change what it does in the future. Oh, you want
to use the new version? Psych! We haven't actually done anything yet.
Use not instead." It creates a weird void in Python 3.6 where the
operator still exists but absolutely nobody has a legitimate reason to
be using it.

What happens if somebody is using ~ for its current semantics, skips
the 3.6 release in their upgrade path, and doesn't read the release
notes carefully enough? They'll never see the warning and will just
experience a silent and difficult-to-diagnose breakage.

More information about the Python-ideas mailing list