Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Grégory Lielens
A small remark for Todd's proposal: I think you should treat the new not (bNOT in the original proposal) differently: it's not binary, so it should not have 2 dunders, the right one is not needed (or there is only the right one, in a way, but other unary ops use the classic dunder iirc...) Also

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Neil Girdhar
Oh, I see, I thought he wanted to override the original logical operators. I don't like adding more operators just to make symbolic equation generation simpler. I think keeping the language simple and using the "numpy.logical_and" function is better than making the language more complicated for a

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Steven D'Aprano
On Mon, Aug 06, 2018 at 02:44:24PM -0700, Neil Girdhar wrote: > This doesn't work because the logical Boolean operators short circuit in > Python. So you could not even define these operators for the regular > Python types. Todd is not proposing to add dunder methods for the existing "or" and

Re: [Python-ideas] Syntactic sugar to declare partial functions

2018-08-06 Thread Neil Girdhar
By the way, these are not "partial functions", and shouldn't be called that. These are "partial function applications". On Saturday, August 4, 2018 at 12:03:50 PM UTC-4, Fabrizio Messina wrote: > > > Hello, I would like to propose a new method to create a partial function. > > At the moment we

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Neil Girdhar
This doesn't work because the logical Boolean operators short circuit in Python. So you could not even define these operators for the regular Python types. Your two examples numpy and SQLAlchemy don't want this short-circuiting behavior, so you would never want to write anything like (some_ar

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Chris Barker via Python-ideas
On Mon, Aug 6, 2018 at 11:11 AM, Chris Barker wrote: > So any new class that doesn't already make use of the bitwise operators > can do that. > just like set() -- which I think has been mentioned here already. -CHB -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA

Re: [Python-ideas] Revisiting dedicated overloadable boolean operators

2018-08-06 Thread Chris Barker via Python-ideas
On Fri, Aug 3, 2018 at 9:13 PM, Todd wrote: > >> Also, in a common use-case, bitwise-and behaves the same as logical_and, >> e.g. >> >> if (arr > x) & (arr2 == y) >> >> This "works" because both arrays being bitwise-anded are boolean arrays. >> > > There are a few problems with using the bitwise