Partial Function Application and implicit self problem

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Mar 27 07:05:11 EDT 2008


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' ?-)





More information about the Python-list mailing list