On 2016-04-07 08:15, Ethan Furman wrote:
On 04/07/2016 12:46 AM, Antoine Pitrou wrote:
How about changing the behaviour of bool.__invert__ to make it in line with the Numpy boolean? (i.e. bool.__invert__ == operator.not_)
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.
Let's not forget that subclasses don't have to exactly duplicate all the behavior of their superclasses. That's why there's such a thing as overriding. Bool could remain a subclass of int, and still change its __invert__ behavior by overriding __invert__. It's true that this would be a backwards incompatible change, but behavior like ~True==-2 doesn't seem like something a lot of people are relying on. It would be worth looking into how much code actually does rely on it. -- Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown