Partial Function Application -- Advantages over normal function?

Terry Reedy tjreedy at udel.edu
Tue Jul 19 12:47:14 EDT 2011


On 7/19/2011 6:07 AM, Dave Angel wrote:
> On 01/-10/-28163 02:59 PM, Thomas 'PointedEars' Lahn wrote:
>> Dave Angel wrote:
>>
>>> On 01/-10/-28163 02:59 PM, Terry Reedy wrote:
>>>> def makeadder(y)
>>>> def _add(x): return x+y
>>>> add2 = makeadder(2)
>>> A couple of typos in that code:
>>>
>>>
>>> def makeaddr(y):
>>> def _add(x): return x+y
>>> return _add
>> I agree about the `return' statement, but not about the factory name;
>> this
>> has nothing to do with addresses (addr).
>>
>
> The two changes that I made deliberately were adding the colon and
> adding the return statement. I'm not sure how the name got changed; that
> was accidental.

Anyway, my apologies for posting quickly without testing and without 
saying so. I know better and too often leave in mistakes when I do.

-- 
Terry Jan Reedy




More information about the Python-list mailing list