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

2018-08-14 Thread Chris Barker - NOAA Federal via Python-ideas
> > Do we often call functools.partial on arbitrary callable objects that we > don't know in advance? For my part, I don’t think I’ve ever used partial in production code. It just seems easier to simply fo it by hand with a closure ( Am I using that term right? I still don’t quite get the terminol

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

2018-08-14 Thread Steven D'Aprano
On Mon, Aug 13, 2018 at 07:46:49PM +0200, Stefan Behnel wrote: > Michel Desmoulin schrieb am 09.08.2018 um 18:59: > > I'd rather have functools.partial() to be added as a new method on > > function objects. [...] > > add_2 = add.partial(2) > > Except that this only works for functions, not for oth

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

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 7:58 AM, Greg Ewing wrote: > Chris Angelico wrote: >> >> No, lambda calculus isn't on par with brakes - but anonymous functions >> are, and if they're called "lambda", you just learn that. > > > It's like saying that people would find it easier to learn to > drive if "brake

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

2018-08-13 Thread MRAB
On 2018-08-14 02:46, Michael Selik wrote: On Mon, Aug 13, 2018, 5:48 PM Greg Ewing > wrote: Chris Angelico wrote: > No, lambda calculus isn't on par with brakes - but anonymous functions > are, and if they're called "lambda", you just lear

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

2018-08-13 Thread David Mertz
Pedantically, Python's lambda isn't even the same thing as in the lambda calculus. The mathematical abstraction is always curried, and neither Python nor most languages that use the spelling 'lambda' do that. So even assuming users must learn technical vocabulary, this is an inaccurate such term.

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

2018-08-13 Thread Michael Selik
On Mon, Aug 13, 2018, 5:48 PM Greg Ewing wrote: > Chris Angelico wrote: > > No, lambda calculus isn't on par with brakes - but anonymous functions > > are, and if they're called "lambda", you just learn that. > > It's like saying that people would find it easier to learn to > drive if "brakes" we

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

2018-08-13 Thread Greg Ewing
Chris Angelico wrote: No, lambda calculus isn't on par with brakes - but anonymous functions are, and if they're called "lambda", you just learn that. It's like saying that people would find it easier to learn to drive if "brakes" were called "stoppers" or something. I don't think that's true.

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

2018-08-13 Thread Abe Dillon
[Steven D'Aprano] > - I accept that there've been a few cases where I could have > chosen my words better, and consequently I've rubbed Abe > the wrong way; sorry about that Abe, as I said earlier (and > I meant it) I have no grudge against you. Thank you. I hold no grudge against you eith

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

2018-08-13 Thread Greg Ewing
Abe Dillon wrote: [Bruce Leban] Lambda calculus IS computer science. It's a foundation of computer science. That doesn't mean it "IS" computer science. Set theory is a foundation of computer science. It's still it's own discipline. Lambda calculus is considered a part of computers scie

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

2018-08-13 Thread Steven D'Aprano
TL;DR - I accept that there've been a few cases where I could have chosen my words better, and consequently I've rubbed Abe the wrong way; sorry about that Abe, as I said earlier (and I meant it) I have no grudge against you. - The most important technical issue I wanted to get from my d

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

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 6:26 AM, Abe Dillon wrote: > [Chris Angelico] >> >> > The whole point of a programming language is to bridge the gap between >> > machine code and natural language (in Python's case English, as with >> > most >> > other languages). It's to make reading and writing code easi

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

2018-08-13 Thread Abe Dillon
[Chris Angelico] > > The whole point of a programming language is to bridge the gap between > > machine code and natural language (in Python's case English, as with most > > other languages). It's to make reading and writing code easier through > > abstraction, not to create ivory towers through t

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

2018-08-13 Thread MRAB
On 2018-08-13 20:08, Abe Dillon wrote: [Bruce Leban] Lambda calculus IS computer science. It's a foundation of computer science. That doesn't mean it "IS" computer science. Set theory is a foundation of computer science. It's still it's own discipline. [snip] The word "is" can mean, am

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

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 5:08 AM, Abe Dillon wrote: > The whole point of a programming language is to bridge the gap between > machine code and natural language (in Python's case English, as with most > other languages). It's to make reading and writing code easier through > abstraction, not to cre

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

2018-08-13 Thread Abe Dillon
[Bruce Leban] > Lambda calculus IS computer science. It's a foundation of computer science. That doesn't mean it "IS" computer science. Set theory is a foundation of computer science. It's still it's own discipline. [Bruce Leban] > Rejecting lambda as CS is as bad as rejecting the + operator b

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

2018-08-13 Thread Chris Angelico
On Tue, Aug 14, 2018 at 4:00 AM, Bruce Leban wrote: > And as to saying a lambda function is an "anonymous function": the anonymity > is not a property of the function. If I assign it to a name, it's no longer > anonymous. Really a "lambda" or "lambda function" is just a function, but > "lambda" is

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

2018-08-13 Thread Bruce Leban
On Sun, Aug 12, 2018 at 8:31 PM, Abe Dillon wrote: > > [Steven D'Aprano] > >> ...if we aren't even willing to move out of our own comfort zone to >> the extent of learning accurate jargon terms from our own profession? > > > Very few of us are computer scientists by profession. That's not even >

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

2018-08-13 Thread Stefan Behnel
Michel Desmoulin schrieb am 09.08.2018 um 18:59: > I'd rather have functools.partial() to be added as a new method on > function objects. > >> from functools import partial >> >> def add(x:int,y:int)->int: >> returnx +y >> >> add_2 = partial(add,2) > > Would become: > > add_2 = add.partial(2

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

2018-08-13 Thread Alex Walters
> -Original Message- > From: Python-ideas list=sdamon@python.org> On Behalf Of Abe Dillon > Sent: Monday, August 13, 2018 12:56 AM > To: Chris Angelico > Cc: Python-Ideas > Subject: Re: [Python-ideas] Syntactic sugar to declare partial functio

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

2018-08-12 Thread Abe Dillon
[Chris Angelico] > lst.onselect = anonfunc(print(target_item)) > What's target_item? If you can't see the signature and see that it's a > parameter, you should look externally for it. If you're not even going to read the explanation I've already given, then I have no reason to respond. Your exam

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

2018-08-12 Thread Chris Angelico
On Mon, Aug 13, 2018 at 2:56 PM, Abe Dillon wrote: > [Chris Angelico] >> >> Also, the signature is most decidedly NOT obvious from context > > Who decided this? It's been decided by some committee? When you write a key > function, you don't know how many arguments are going to be passed? lst.onse

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

2018-08-12 Thread Abe Dillon
[Alex Walters] > He is questioning the concept that the lambda keyword has caused any > harm. You assert that it caused minor harm. Minor harm can still be real, > significant, and non-trivial. What, exactly, is the difference between "minor" and "non-trivial" and when did I say the harm was "s

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

2018-08-12 Thread Chris Angelico
On Mon, Aug 13, 2018 at 1:31 PM, Abe Dillon wrote: > [Steven D'Aprano] >> >> Just because I challenge your statements doesn't mean I'm attacking you. > > > No. Telling me I'm having an extreme overreaction means you're attacking me. If your reaction was extreme, saying so isn't attacking you. >

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

2018-08-12 Thread Alex Walters
> [Steven D'Aprano] > > > You've said that the choice of keyword, "lambda", has caused harm. > Given > the chance to clarify what you meant, you stood by your comment > that the > choice of keyword "lambda" has done real, significant, non-trivial > harm > to Python (the la

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

2018-08-12 Thread Abe Dillon
[Steven D'Aprano] > Just because I challenge your statements doesn't mean I'm attacking you. No. Telling me I'm having an extreme overreaction means you're attacking me. Pushing the narrative that I'm irrational by enumerating the least charitable interpretations of my words possible then claimi

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

2018-08-12 Thread Steven D'Aprano
Answering a few of Abe's comments out of order... On Fri, Aug 10, 2018 at 05:20:25PM -0500, Abe Dillon wrote: > I didn't realize I'd hit such a nerve. [...] I'm truly sorry > if I hurt your feelings. [...] > But you seem to have some grudge against me. I don't get all the > outrage over what I tho

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

2018-08-11 Thread Robert Vanden Eynde
Therefore one can do a decorator that gives .partial: def partialize(f): from functools import partial f.partial = lambda *a, **b: partial(f, *a, **b) return f @partialize def f(x,y): return x-y g = f.partial(5) g(3) That's the same idea as funcoperators.partially but doesn't re

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

2018-08-11 Thread Robert Vanden Eynde
Le sam. 11 août 2018 à 10:34, Vincent Maillol a écrit : > Hello, > > Currently the user defined functions are mutables, there can be existed > python codes like this: > > >>> def foo(): > ... pass > ... > >>> if not hasattr(foo, 'partial'): > ... foo.partial = {} > ... > > Adding a new me

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

2018-08-11 Thread Vincent Maillol
Hello, Currently the user defined functions are mutables, there can be existed python codes like this: >>> def foo(): ... pass ... >>> if not hasattr(foo, 'partial'): ... foo.partial = {} ... Adding a new method to function object can break existing projects, but it is without impact wit

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

2018-08-10 Thread Abe Dillon
[Neil Girdhar] > > ... I don't find the google-ablilty argument super strong because > there are many constructs that are difficult to google, but still pretty > great (e.g. comprehensions). > Not that it matters, but comprehension is a standard term in mathematics > and computer science apparent

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

2018-08-10 Thread Neil Girdhar
On Fri, Aug 10, 2018 at 6:21 PM Abe Dillon wrote: > [Neil Girdhar] > > I prefer partial since many programmers studied computer science > > > Many did not. I studied electrical engineering and wouldn't have been able > to tell you what the word 'partial' meant four years ago even though I've > be

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

2018-08-10 Thread Abe Dillon
[Neil Girdhar] > I prefer partial since many programmers studied computer science Many did not. I studied electrical engineering and wouldn't have been able to tell you what the word 'partial' meant four years ago even though I've been programming in one form or another since the late nineties.

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

2018-08-10 Thread Steven D'Aprano
On Thu, Aug 09, 2018 at 01:32:00PM -0500, Abe Dillon wrote: > I'd like to push for the less jargon-y `func.given()` version if this gains > traction. Not only is it shorter, it's a much more common term with a clear > meaning. It's a clear, *generic* meaning that doesn't have any association with

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

2018-08-09 Thread Jacco van Dorp
I actually really like the method-on-function-object syntax. +1, for what it's worth from someone like me. 2018-08-10 0:46 GMT+02:00 Neil Girdhar : > I prefer partial since many programmers studied computer science, and also > it makes the concepts easier to google. > > Anyway, I don't actually wa

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

2018-08-09 Thread Neil Girdhar
I prefer partial since many programmers studied computer science, and also it makes the concepts easier to google. Anyway, I don't actually want either a partial member nor new syntax for this, but if I had to choose, I'd choose no new syntax. On Thu, Aug 9, 2018 at 2:32 PM Abe Dillon wrote: >

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

2018-08-09 Thread Abe Dillon
I'd like to push for the less jargon-y `func.given()` version if this gains traction. Not only is it shorter, it's a much more common term with a clear meaning. Words like 'partial', 'curry', 'lambda', and 'closure' are fine for text books, published papers, and technical discussion, but I think th

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

2018-08-09 Thread Neil Girdhar
That's a nicer solution to me. On Thu, Aug 9, 2018 at 1:00 PM Michel Desmoulin wrote: > I'd rather have functools.partial() to be added as a new method on > function objects. > > > > > fromfunctools importpartial > > > > > > def add(x:int,y:int)->int: > > returnx +y > > > > > > add_2 = parti

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

2018-08-09 Thread Michel Desmoulin
I'd rather have functools.partial() to be added as a new method on function objects. > > fromfunctools importpartial > > > def add(x:int,y:int)->int: > returnx +y > > > add_2 = partial(add,2) > Would become: add_2 = add.partial(2) Nothing to change on the parser, no obscure syntax for futur

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] Syntactic sugar to declare partial functions

2018-08-04 Thread Robert Vanden Eynde
You can read the other functionalities on the project page : https://pypi.org/project/funcoperators/ And if you want to solve the "can't partial from right that allows to use the Ellipsis '...' : # the built-in "pow" doesn't take keyword arguments, so partial can't be used. from funcoperators im

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

2018-08-04 Thread Daniel.
That's an awesome library! Congratulation for doing this and thanks for sharing! Em sáb, 4 de ago de 2018 às 13:42, Robert Vanden Eynde escreveu: > The funcoperators lib on pypi does exactly that: > > from funcoperators import partially > > @partially > def add(x: int, y: int) -> int: > retu

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

2018-08-04 Thread Steven D'Aprano
On Sat, Aug 04, 2018 at 09:03:50AM -0700, Fabrizio Messina wrote: > At the moment we have to load the *partial* function from the *functool* > library, and apply it to an existing function [...] > While partial expose the mechanism excellently its instantiation method is, > at times, not very f

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

2018-08-04 Thread Jonathan Fine
Here's my opinion, in a nutshell. A diet with a small amount of sugar is healthy. But too much sugar is not. https://www.nhs.uk/live-well/eat-well/how-does-sugar-in-our-diet-affect-our-health/ I have a similar attitude to syntactic sugar. Sometimes helpful. https://news.ycombinator.com/item?id=16

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

2018-08-04 Thread Robert Vanden Eynde
> @partiallymulti > def stuff(x,y,z): > return x - y + 2*z > f = stuff[1,2] f(4) ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/

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

2018-08-04 Thread Robert Vanden Eynde
The funcoperators lib on pypi does exactly that: from funcoperators import partially @partially def add(x: int, y: int) -> int: return x + y add_2 = add[2] @partiallymulti def stuff(x,y,z): return x - y + 2*z sort = partially(sorted) sort_by_x = sort.key(key=lambda element: element.x)

[Python-ideas] Syntactic sugar to declare partial functions

2018-08-04 Thread Fabrizio Messina
Hello, I would like to propose a new method to create a partial function. At the moment we have to load the *partial* function from the *functool* library, and apply it to an existing function, e.g. from functools import partial def add(x: int, y: int) -> int: return x + y add_2 = par