Lambda forms and scoping

alex goretoy aleksandr.goretoy at gmail.com
Mon Mar 23 02:21:56 CET 2009


I'm talking about in function c, where we bind the function call, kinda same
thing with lambdas too, exactly same

def func1(a):
    return a
def func2(a="",b=0):
    return "%s has %d apples"%(a,b)
def c(f1,f2,**kwargs):
    print f2(kwargs['name'], f1(kwargs['apple'])) #bind call to function 1
and return from a bound function 2

bollox=42
>>> d={bollox: (c,(func1,func2)} # call c, which is bound, passing in func1
and func2 unbound, function pointer
>>> print d[bollox][0](func1,func2,name="fred flinstone",apple=bollox)
fred flinstone has 42 apples

-Alex Goretoy
http://www.goretoy.com

Fred Allen  - "The first time I sang in the church choir; two hundred people
changed their religion."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090322/1f6030aa/attachment.html>


More information about the Python-list mailing list