Re: [Python-Dev] Partial function application

2015-09-11 Thread Terry Reedy
On 9/11/2015 3:56 AM, Herbert Kruitbosch wrote: I was wondering if there are considerations for including partial function application syntactically. I very often find myself writing statements as: data_sorted = sort(data, key = lambda x: x[0]) where I would prefer data_sorted = sort(data, key

Re: [Python-Dev] Partial function application

2015-09-11 Thread Herbert Kruitbosch
> On Fri, 11 Sep 2015 at 10:41 Herbert Kruitbosch > wrote: > __ >> data_sorted = sort(data, key = #1[0]) > > That syntax won't work because `#` is used to start a comment and > there is no way to disambiguate that in the grammar. Obviously :) The #-syntax is used by Mathematica, which is why I u

Re: [Python-Dev] Partial function application

2015-09-11 Thread Brett Cannon
On Fri, 11 Sep 2015 at 10:41 Herbert Kruitbosch < python-...@herbertkruitbosch.com> wrote: > Dear developers, > > First of all, I'm a programmer for a data science company and I recently > graduated. > > That being said, I have wondered why python does not have syntactical > support (like syntax s

Re: [Python-Dev] Partial function application 'from the right'

2009-02-06 Thread Xavier Morel
On 5 Feb 2009, at 23:54 , Steven D'Aprano wrote: Raymond Hettinger wrote: The arguments for and against the patch could be brought against partial() itself, so I don't understand the -1's at all. Quite so, but that doesn't justify adding more capabilities to partial(). I concur with Coll

Re: [Python-Dev] Partial function application 'from the right'

2009-02-06 Thread Nick Coghlan
Ben North wrote: > Hi, > > My reading of the most recent set of emails on this topic is that the > balance of opinion is against adding a 'partial_right' or 'partial.skip' > feature. I still think such a feature would be of real use, although I > can see the arguments against adding it. Is the c

Re: [Python-Dev] Partial function application 'from the right'

2009-02-05 Thread Steven D'Aprano
Raymond Hettinger wrote: The arguments for and against the patch could be brought against partial() itself, so I don't understand the -1's at all. Quite so, but that doesn't justify adding more capabilities to partial(). I concur with Collin. Lever arguments are a road to bloat. One pers

Re: [Python-Dev] Partial function application 'from the right'

2009-02-03 Thread Raymond Hettinger
I still haven't seen any real code presented that would benefit from partial.skip or partial_right. # some Articles have timestamp attributes and some don't stamp = partial_right(getattr, 'timestamp', 0) lastupdate = max(map(stamp, articles)) # some beautiful soup nodes have a name attribute an

Re: [Python-Dev] Partial function application 'from the right'

2009-02-03 Thread Collin Winter
On Tue, Feb 3, 2009 at 11:53 AM, Antoine Pitrou wrote: > Collin Winter gmail.com> writes: >> >> Have any of the original objections to Calvin's patch >> (http://bugs.python.org/issue1706256) been addressed? If not, I don't >> see anything in these threads that justify resurrecting it. >> >> I sti

Re: [Python-Dev] Partial function application 'from the right'

2009-02-03 Thread Antoine Pitrou
Collin Winter gmail.com> writes: > > Have any of the original objections to Calvin's patch > (http://bugs.python.org/issue1706256) been addressed? If not, I don't > see anything in these threads that justify resurrecting it. > > I still haven't seen any real code presented that would benefit fro

Re: [Python-Dev] Partial function application 'from the right'

2009-02-03 Thread Calvin Spealman
http://bugs.python.org/issue1706256 Took me a couple days to catch up on this thread so here is the link for any interested. Could it be possible to reevaluate this? On Sat, Jan 31, 2009 at 2:40 PM, Leif Walsh wrote: > On Fri, Jan 30, 2009 at 7:38 PM, Calvin Spealman wrote: >> I am just replyin

Re: [Python-Dev] Partial function application 'from the right'

2009-02-03 Thread Collin Winter
On Tue, Feb 3, 2009 at 5:44 AM, Ben North wrote: > Hi, > > Thanks for the further responses. Again, I'll try to summarise: > > Scott David Daniels pointed out an awkward interaction when chaining > partial applications, such that it could become very unclear what was > going to happen when the fi

Re: [Python-Dev] Partial function application 'from the right'

2009-01-31 Thread Leif Walsh
On Fri, Jan 30, 2009 at 7:38 PM, Calvin Spealman wrote: > I am just replying to the end of this thread to throw in a reminder > about my partial.skip patch, which allows the following usage: > > split_one = partial(str.split, partial.skip, 1) > > Not looking to say "mine is better", but if the ide

Re: [Python-Dev] Partial function application 'from the right'

2009-01-30 Thread Alexander Belopolsky
On Fri, Jan 30, 2009 at 7:42 PM, Antoine Pitrou wrote: .. > If one writes X = partial.skip, it looks quite nice: > > split_one = partial(str.split, X, 1) Or even _ = partial.skip split_one = partial(str.split, _, 1) ___ Python-Dev mailing list Python-D

Re: [Python-Dev] Partial function application 'from the right'

2009-01-30 Thread Antoine Pitrou
Calvin Spealman gmail.com> writes: > > I am just replying to the end of this thread to throw in a reminder > about my partial.skip patch, which allows the following usage: > > split_one = partial(str.split, partial.skip, 1) > > Not looking to say "mine is better", but if the idea is being given

Re: [Python-Dev] Partial function application 'from the right'

2009-01-30 Thread Calvin Spealman
I am just replying to the end of this thread to throw in a reminder about my partial.skip patch, which allows the following usage: split_one = partial(str.split, partial.skip, 1) Not looking to say "mine is better", but if the idea is being given merit, I like the skipping arguments method better

Re: [Python-Dev] Partial function application 'from the right'

2009-01-30 Thread Mike Klaas
On 29-Jan-09, at 3:38 PM, Daniel Stutzbach wrote: On Thu, Jan 29, 2009 at 5:24 PM, Mike Klaas wrote: And yet, python isn't confined to mathematical notation. *, ** are both overloaded for use in argument lists to no-one's peril, AFAICT. Certainly, but there is no danger of confusion them

Re: [Python-Dev] Partial function application 'from the right'

2009-01-30 Thread Scott David Daniels
s...@blueyonder.co.uk wrote: Hi all, On Thu, Jan 29, 2009 at 6:12 AM, Ben North wrote: I find 'functools.partial' useful, but occasionally I'm unable to use it because it lacks a 'from the right' version. -1 For me, the main objection to a partial that places its stored positional arguments

Re: [Python-Dev] Partial function application 'from the right'

2009-01-30 Thread scav
Hi all, > On Thu, Jan 29, 2009 at 6:12 AM, Ben North wrote: >> Hi, >> >> I find 'functools.partial' useful, but occasionally I'm unable to use it >> because it lacks a 'from the right' version. > -1 For me, the main objection to a partial that places its stored positional arguments from the rig

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Andrew Bennetts
Mike Klaas wrote: > On 29-Jan-09, at 3:21 PM, Daniel Stutzbach wrote: [...] >> The meaning which numpy attributes to Ellipsis is also the meaning >> that mathematical notation has attached to Ellipsis for a very long >> time. > > And yet, python isn't confined to mathematical notation. *, ** a

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Daniel Stutzbach
On Thu, Jan 29, 2009 at 5:24 PM, Mike Klaas wrote: > And yet, python isn't confined to mathematical notation. *, ** are both > overloaded for use in argument lists to no-one's peril, AFAICT. > Certainly, but there is no danger of confusion them for multiplication in context, whereas: split_com

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Collin Winter
On Thu, Jan 29, 2009 at 6:12 AM, Ben North wrote: > Hi, > > I find 'functools.partial' useful, but occasionally I'm unable to use it > because it lacks a 'from the right' version. E.g., to create a function > which splits a string on commas, you can't say > > # Won't work when called: > split

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Mike Klaas
On 29-Jan-09, at 3:21 PM, Daniel Stutzbach wrote: On Thu, Jan 29, 2009 at 4:04 PM, Antoine Pitrou wrote: Alexander Belopolsky gmail.com> writes: > By this analogy, partial(f, ..., *args) is right_partial with '...' > standing for any number of missing arguments. I you want to specify > exac

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Daniel Stutzbach
On Thu, Jan 29, 2009 at 4:04 PM, Antoine Pitrou wrote: > Alexander Belopolsky gmail.com> writes: > > By this analogy, partial(f, ..., *args) is right_partial with '...' > > standing for any number of missing arguments. I you want to specify > > exactly one missing argument, you would want to wr

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Antoine Pitrou
Nick Coghlan gmail.com> writes: > > If partial starts messing about looking for missing arguments and then > slotting them in, then it is likely to slow down to the point where you > would be better off skipping it and writing a dedicated function that > adds the extra arguments. Looking for mis

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Nick Coghlan
Leif Walsh wrote: > That said, it seems to me that if we're going to add to > functools.partial, we should go all the way and allow keyword > arguments (or a dict of them, if it's otherwise too hard to > implement). Otherwise, in another few {days, weeks, months} we'll see > another thread like th

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Antoine Pitrou
Alexander Belopolsky gmail.com> writes: > > By this analogy, partial(f, ..., *args) is right_partial with '...' > standing for any number of missing arguments. I you want to specify > exactly one missing argument, you would want to write partial(f, :, > *args), which is not a valid syntax even i

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Leif Walsh
On Thu, Jan 29, 2009 at 9:12 AM, Ben North wrote: > I find 'functools.partial' useful, but occasionally I'm unable to use it > because it lacks a 'from the right' version. E.g., to create a function > which splits a string on commas, you can't say First of all, many functions like this are easy

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Alexander Belopolsky
This discussion probably belongs to python-ideas, but since we already have this thread, I'll reply here instead of opening a new thread there. Ellipsis was introduced into python to serve needs of the numeric python community. If you think of numpy multiarrays as functions taking ndim number of

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Antoine Pitrou
Scott David Daniels Acm.Org> writes: > > Antoine Pitrou wrote: > > ... > > In py3k, we could also use "..." (the Ellipsis object) to denote > > places where an argument is missing, so that: > > split_comma = partial(str.split, ..., ',') > > would do what you want. > > Thus preventing any us

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Scott David Daniels
Antoine Pitrou wrote: ... In py3k, we could also use "..." (the Ellipsis object) to denote places where an argument is missing, so that: split_comma = partial(str.split, ..., ',') would do what you want. Thus preventing any use of partial when an argument could be an the Ellipsis instance

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Antoine Pitrou
Hello, Ben North redfrontdoor.org> writes: > > I find 'functools.partial' useful, but occasionally I'm unable to use it > because it lacks a 'from the right' version. E.g., to create a function > which splits a string on commas, you can't say > ># Won't work when called: >split_comma

Re: [Python-Dev] Partial function application 'from the right'

2009-01-29 Thread Terry Reedy
Ben North wrote: I find 'functools.partial' useful, but occasionally I'm unable to use it because it lacks a 'from the right' version. ... Would there be any interest in this? I think so. Post your patch to the tracker. Even if eventually rejected, it will be there for people to use. _