Partial Function Application and implicit self problem

castironpi at gmail.com castironpi at gmail.com
Thu Mar 27 07:38:24 EDT 2008


On Mar 27, 6:05 am, Bruno Desthuilliers <bruno.
42.desthuilli... at wtf.websiteburo.oops.com> wrote:
> Gabriel Rossetti a écrit :
>
>
>
>
>
> > Bruno Desthuilliers wrote:
> >> Gabriel Rossetti a écrit :
> (snip)
> >>>   registerServiceAtomic = partial(__registerService, True)
> >>> registerServiceNonAtomic = partial(__registerService, False)
>
> >>> I should pass self when applying partial, but then I can't do that
> >>> since self is not available there. Does anyone have any ideas?
>
> >> registerServiceAtomic = partial(__registerService, atomic=True)
> >> registerServiceNonAtomic = partial(__registerService, atomic=False)
>
> >> Caveat: you'll have to either invert the order of the atomic and
> >> service params, or call the partials with named arg for service.
>
> > Ok, thanks, I didn't know you could do that, I though partial was always
> > left to right
>
> It's left to right for positional arguments. Using named arguments, you
> can pass them in whatever order.
>
> > (I had read that about curry)
>
> Which 'curry' ?-)

I think 'prefix' should go in there.  Can you try: partial( G.f, a, b )
( self= obj )?  (If that's too brief let me know.)



More information about the Python-list mailing list