Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Greg Ewing
Richard Damon wrote: Rémi, I believe, is assuming in their example that by defining the field of mathematics being used, there is at least an implicit definition (if not actually explicit as such a statement would typically be preceded by definitions) definition of the types of the variables. I

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Terry Reedy
On 3/16/2019 8:01 AM, Gustavo Carneiro wrote: On Sat, 16 Mar 2019 at 10:33, Steven D'Aprano > wrote: The question this PEP is trying to answer is not "can we support every use-case imaginable for a merge operator?" but "can we support the most typical u

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Gregory P. Smith
On Sat, Mar 16, 2019 at 5:02 AM Gustavo Carneiro wrote: > On Sat, 16 Mar 2019 at 10:33, Steven D'Aprano wrote: > >> On Fri, Mar 15, 2019 at 10:53:31PM +, MRAB wrote: >> >> > There was also the suggestion of having both << and >>. >> > >> > Actually, now that dicts are ordered, that would pro

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Richard Damon
On 3/16/19 8:14 AM, Dan Sommers wrote: > On 3/16/19 6:17 AM, Richard Damon wrote: >> On 3/16/19 4:39 AM, Greg Ewing wrote: >>> Rémi Lapeyre wrote: I think this omit a very important property of mathematic equations thought, maths is a very strongly typed language which can be a signi

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Kirill Balunov
сб, 16 мар. 2019 г. в 16:02, Kirill Balunov : > Thank you for this very thoughtful message! It reminded me of my first > experience with the old Fortran code. You probably know that earlier in > Fortran there were no cryptic shortcuts for writing relational operators: > instead of `A >= B`, you ha

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Kirill Balunov
Thank you for this very thoughtful message! It reminded me of my first experience with the old Fortran code. You probably know that earlier in Fortran there were no cryptic shortcuts for writing relational operators: instead of `A >= B`, you had to write `A .GE. B`, or as many often wrote this with

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Rémi Lapeyre
Le 16 mars 2019 à 10:02:31, Greg Ewing (greg.ew...@canterbury.ac.nz(mailto:greg.ew...@canterbury.ac.nz)) a écrit: > Rémi Lapeyre wrote: > > I think this omit a very important property of > > mathematic equations thought, maths is a very strongly typed language > > which can be a significant improv

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Rémi Lapeyre
Le 16 mars 2019 à 13:15:37, Dan Sommers (2qdxy4rzwzuui...@potatochowder.com(mailto:2qdxy4rzwzuui...@potatochowder.com)) a écrit: > On 3/16/19 6:17 AM, Richard Damon wrote: > > On 3/16/19 4:39 AM, Greg Ewing wrote: > >> Rémi Lapeyre wrote: > >>> I think this omit a very important property of > >>>

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Rémi Lapeyre
Le 16 mars 2019 à 13:15:37, Dan Sommers (2qdxy4rzwzuui...@potatochowder.com(mailto:2qdxy4rzwzuui...@potatochowder.com)) a écrit: > On 3/16/19 6:17 AM, Richard Damon wrote: > > On 3/16/19 4:39 AM, Greg Ewing wrote: > >> Rémi Lapeyre wrote: > >>> I think this omit a very important property of > >>>

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Dan Sommers
On 3/16/19 6:17 AM, Richard Damon wrote: On 3/16/19 4:39 AM, Greg Ewing wrote: Rémi Lapeyre wrote: I think this omit a very important property of mathematic equations thought, maths is a very strongly typed language which can be a significant improvement for readability. Python is very strong

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Gustavo Carneiro
On Sat, 16 Mar 2019 at 10:33, Steven D'Aprano wrote: > On Fri, Mar 15, 2019 at 10:53:31PM +, MRAB wrote: > > > There was also the suggestion of having both << and >>. > > > > Actually, now that dicts are ordered, that would provide a use-case, > > because you would then be able to choose whic

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Richard Damon
On 3/16/19 4:39 AM, Greg Ewing wrote: > Rémi Lapeyre wrote: >> I think this omit a very important property of >> mathematic equations thought, maths is a very strongly typed language >> which can be a significant improvement for readability. > > Python is very strongly typed too, so I don't really

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Steven D'Aprano
On Sat, Mar 16, 2019 at 06:43:52AM +0400, Abdur-Rahmaan Janhangeer wrote: > Despite my poor python skills, i don't think i'd ever use this one. > > blocks = blocks + [block] # Not good for you. Neither would I. But I would use: result = process(blocks + [block]) in pr

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Antoine Pitrou
On Fri, 15 Mar 2019 10:51:11 -0700 Guido van Rossum wrote: > Of course, everything comes at a price. You have to learn the operators, > and you have to learn their properties when applied to different object > types. That's not the only price, though. If "+" is added to dicts, then we're overloa

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-16 Thread Antoine Pitrou
On Sat, 16 Mar 2019 03:44:02 +1100 Steven D'Aprano wrote: > On Fri, Mar 15, 2019 at 12:34:45PM +0100, Antoine Pitrou wrote: > > On Thu, 7 Mar 2019 10:58:02 +1100 > > Chris Angelico wrote: > > > > > > Lots of words that basically say: Stuff wouldn't be perfectly pure. > > > > Chris, please l

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-16 Thread Antoine Pitrou
On Sat, 16 Mar 2019 01:59:07 +1100 Steven D'Aprano wrote: > On Fri, Mar 15, 2019 at 12:25:22PM +0100, Antoine Pitrou wrote: > > > Yeah, well I do think "+=" for lists was a mistake. I *still* have > > trouble remembering the exact difference between "list +=" and > > "list.extend" (yes, ther

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-16 Thread Antoine Pitrou
On Sat, 16 Mar 2019 01:41:59 +1100 Steven D'Aprano wrote: > > Matrix multiplication is a perfect example: adding the @ operator could > have been done in Python 0.1 if anyone had thought of it, but it took 15 > years of numerical folk "whinging" about the lack until it happened: Not so perfect

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Steven D'Aprano
On Fri, Mar 15, 2019 at 10:53:31PM +, MRAB wrote: > There was also the suggestion of having both << and >>. > > Actually, now that dicts are ordered, that would provide a use-case, > because you would then be able to choose which values were overwritten > whilst maintaining the order of the

[Python-ideas] Not all operators are useful (was Why operators are useful)

2019-03-16 Thread Serhiy Storchaka
15.03.19 19:51, Guido van Rossum пише: There's been a lot of discussion about an operator to merge two dicts. I participated in the beginning but quickly felt overwhelmed by the endless repetition, so I muted most of the threads. But I have been thinking about the reason (some) people like ope

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-16 Thread Stefan Krah
On Sat, Mar 16, 2019 at 09:04:22PM +1300, Greg Ewing wrote: > Another random thought about this: Mathematicians use addition as a > metaphor for quite a range of different things, but they tend to only > use the symbols ∪ and ∩ for actual sets, or things that are very > set-like. So maybe that's an

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Greg Ewing
Rémi Lapeyre wrote: I think this omit a very important property of mathematic equations thought, maths is a very strongly typed language which can be a significant improvement for readability. Python is very strongly typed too, so I don't really see how maths is different. For example, a math

Re: [Python-ideas] PEP: Dict addition and subtraction

2019-03-16 Thread Greg Ewing
Another random thought about this: Mathematicians use addition as a metaphor for quite a range of different things, but they tend to only use the symbols ∪ and ∩ for actual sets, or things that are very set-like. So maybe that's an argument for using '+' rather than '|' for dict merging. -- Greg

Re: [Python-ideas] Why operators are useful

2019-03-16 Thread Terry Reedy
I agree with Guido's general comments on operators. Modern arithmetic and algebra really took off with the introduction of operators. On the other hand, I have seen condensed blocks of 'higher math', dense with operators, that I could hardly read, and that reminded me of API or Perl. On 3/15