[Python-ideas] Changing the meaning of bool.__invert__
Eric Snow
ericsnowcurrently at gmail.com
Fri Apr 8 19:08:04 EDT 2016
On Fri, Apr 8, 2016 at 1:34 AM, Nathaniel Smith <njs at pobox.com> wrote:
> The reason I'm uncertain is that in numpy code, using operations like
> ~ on booleans is *very* common, because the whole idea of numpy is
> that it gives you a way to write code that works the same on either a
> single value or on an array of values, and when you're working with
> booleans then this means you have to use '~': '~' works on arrays and
> 'not' doesn't.
Would it be a different story if the logical operators (and, or, not)
had a protocol, e.g. __not__? My guess is that ~ was made to work in
the absence of __not__.
-eric
More information about the Python-ideas
mailing list