[Python-ideas] Changing the meaning of bool.__invert__
Guido van Rossum
guido at python.org
Fri Apr 8 11:00:27 EDT 2016
More information about the Python-ideas mailing list
Fri Apr 8 11:00:27 EDT 2016
- Previous message (by thread): [Python-ideas] Changing the meaning of bool.__invert__
- Next message (by thread): [Python-ideas] Changing the meaning of bool.__invert__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Apr 7, 2016 at 6:40 PM, Steven D'Aprano <steve at pearwood.info> wrote: > You missed two: >> and <<. What are we to do with (True << 1)? [...] Those are indeed ambiguous -- they are defined as multiplication or floor division with a power of two, e.g. x<<n is x*2**n and x>>n is x//2**n (for integral x and nonnegative n). The point of this thread seems to be to see whether some operations can be made more useful by staying in the bool domain -- I don't think making both of these return 0 if n != 0, so let's keep them unchanged. > Even if we "fix" this, surely we should go through the usual deprecation > process? This isn't a critical security bug that needs fixing, it's a > semantic change to something that has worked this way for 25 years, and > its going to break something somewhere. There are just far too many > people that expect that bools are ints. After all, not withstanding > their fancy string representation, they behave like ints and actually > are ints. The thing here is, this change is too small to warrant a __future__ import. So we're either going to introduce it in 3.6 and tell people about it in case their code might break, or we're never going to do it. I'm honestly on the fence, but I feel this is a rarely used operator so changing its meaning is not likely to break a lot of code. -- --Guido van Rossum (python.org/~guido)
- Previous message (by thread): [Python-ideas] Changing the meaning of bool.__invert__
- Next message (by thread): [Python-ideas] Changing the meaning of bool.__invert__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list