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

Hi all,
On Thu, Jan 29, 2009 at 6:12 AM, Ben North <ben@redfrontdoor.org> 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 right is that you don't know which positions those arguments will actually occupy until the partial is called. Who *really* thinks that would be a neat feature? There's probably a reason why Haskell doesn't do this... Peter Harris

scav@blueyonder.co.uk wrote:
Hi all,
On Thu, Jan 29, 2009 at 6:12 AM, Ben North <ben@redfrontdoor.org> 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 from the right is that you don't know which positions those arguments will actually occupy until the partial is called.
Certainly this interacts in a magical way with keyword args. That definitional problem is the reason there was no curry_right in the original recipe that was the basis of the first partial. If you have: def button(root, position, action=None, text='*', color=None): ... ... blue_button = partial(button, my_root, color=(0,0,1)) Should partial_right(blue_button, 'red') change the color or the text? It is computationally hard to do that (may have to chase chains of **kwarg-passing functions), but even hard to document. So, I'd avoid it. --Scott David Daniels Scott.Daniels@Acm.Org
participants (2)
-
scavï¼ blueyonder.co.uk
-
Scott David Daniels