[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-24 Thread Steven D'Aprano
On Wed, Feb 24, 2021 at 12:51:24PM -0500, Richard Damon wrote: > Of the unary, python implements them all, the possible opererators for > op a are: > > True > > False > > a > > not a Those who have read my posts over the years will realise that I enjoy being pedantic as much as the next guy

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-24 Thread Chris Angelico
On Thu, Feb 25, 2021 at 5:05 AM Richard Damon wrote: > > On 2/24/21 12:34 PM, Chris Angelico wrote: > > On Thu, Feb 25, 2021 at 4:28 AM Barry Scott wrote: > >> > >> > >> On 23 Feb 2021, at 22:10, Steven D'Aprano wrote: > >> > >> There are exactly 2**4 = 16 boolean operators of two variables. Pyt

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-24 Thread Richard Damon
On 2/24/21 12:34 PM, Chris Angelico wrote: > On Thu, Feb 25, 2021 at 4:28 AM Barry Scott wrote: >> >> >> On 23 Feb 2021, at 22:10, Steven D'Aprano wrote: >> >> There are exactly 2**4 = 16 boolean operators of two variables. Python >> only supports two: `and` and `or`. Plus a single unary operator

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-24 Thread Richard Damon
On 2/24/21 12:26 PM, Barry Scott wrote: > > >> On 23 Feb 2021, at 22:10, Steven D'Aprano > > wrote: >> >> There are exactly 2**4 = 16 boolean operators of two variables. Python  >> only supports two: `and` and `or`. Plus a single unary operator `not`  >> (out of four pos

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-24 Thread Chris Angelico
On Thu, Feb 25, 2021 at 4:28 AM Barry Scott wrote: > > > > On 23 Feb 2021, at 22:10, Steven D'Aprano wrote: > > There are exactly 2**4 = 16 boolean operators of two variables. Python > only supports two: `and` and `or`. Plus a single unary operator `not` > (out of four possible unary operators).

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-24 Thread Barry Scott
> On 23 Feb 2021, at 22:10, Steven D'Aprano wrote: > > There are exactly 2**4 = 16 boolean operators of two variables. Python > only supports two: `and` and `or`. Plus a single unary operator `not` > (out of four possible unary operators). What makes xnor so special that > you want it to be

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-24 Thread Steven D'Aprano
I don't think we want to add a new dunder just to make it easier for people to abuse bitwise operators instead of using the `!=` operator. -- Steve ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-23 Thread Soni L.
On 2021-02-23 7:10 p.m., Steven D'Aprano wrote: On Tue, Feb 23, 2021 at 01:57:08PM -0300, Soni L. wrote: > What about getting the parser to recognize ^~ as an XNOR operator and > have __xnor__ on bools actually do xnor on bools? Make xnor a real > operator by fusing two operators together!

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-23 Thread Steven D'Aprano
On Tue, Feb 23, 2021 at 01:57:08PM -0300, Soni L. wrote: > 64-bit bools were a mistake, tbh. Oh well, at least we tried. What language are you talking about? In Python, bool is a subclass of int, which is a BigNum, not 64 bits. >>> False.bit_length() 0 >>> (~False).bit_length() 1 > What about

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-23 Thread Soni L.
64-bit bools were a mistake, tbh. Oh well, at least we tried. What about getting the parser to recognize ^~ as an XNOR operator and have __xnor__ on bools actually do xnor on bools? Make xnor a real operator by fusing two operators together! On 2021-02-23 5:49 a.m., Steven D'Aprano wrote: On

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-23 Thread Steven D'Aprano
On Mon, Feb 22, 2021 at 10:11:14PM -0300, Soni L. wrote: > Currently ~False is -1 and ~True is -2. Would be nicer if ~bool was the > same as not bool. That's your opinion. I disagree. Bitwise-not is not the same thing as boolean-not, and they should not be spelled the same, especially not when

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-22 Thread Marco Sulla
On Tue, 23 Feb 2021 at 02:13, Soni L. wrote: > > Currently ~False is -1 and ~True is -2. Would be nicer if ~bool was the > same as not bool. I suspect this is more for NumPy people. I remember that one of my bosses used `~a` on a bool because he started with NumPy and had a limited knowledge of P

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-22 Thread Josh Rosenberg
> You could write it as a ^ (not b), as long as you don't mind it giving back an integer rather than a bool. Actually, that'll give back a bool if a is a bool (and (not b) produces a bool); ^ is overridden for bool/bool operations and itself returns a bool. On Tue, Feb 23, 2021 at 1:48 AM Chris A

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-22 Thread Guido van Rossum
Also, code that is expecting an int should not behave differently when it receives a bool. On Mon, Feb 22, 2021 at 17:47 Chris Angelico wrote: > On Tue, Feb 23, 2021 at 12:14 PM Soni L. wrote: > > > > Currently ~False is -1 and ~True is -2. Would be nicer if ~bool was the > > same as not bool.

[Python-ideas] Re: Deprecate/change the behaviour of ~bool

2021-02-22 Thread Chris Angelico
On Tue, Feb 23, 2021 at 12:14 PM Soni L. wrote: > > Currently ~False is -1 and ~True is -2. Would be nicer if ~bool was the > same as not bool. Hopefully nobody actually relies on this but > nevertheless, it would be a backwards-incompatible change so the whole > deprecation warnings and whatnot w