8 Apr
2016
8 Apr
'16
9:55 p.m.
2016-04-08 17:00 GMT+02:00, Guido van Rossum <guido@python.org>:
On Thu, Apr 7, 2016 at 6:40 PM, Steven D'Aprano <steve@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.
It is also compatible with numpy: np.bool_(True) <<2 4 but there is also minus operator: -np.bool_(True) False -np.bool_(False) True