Closures and Partial Function Application

Travis Parks jehugaleahsa at gmail.com
Wed Aug 31 18:45:28 CEST 2011


I was a little disappointed the other day when I realized that
closures were read-only. I like to use closures quite a bit.

Can someone explain why this limitation exists? Secondly, since I can
cheat by wrapping the thing being closure-ified, how can I write a
simple wrapper that has all the same members as the thing (decorator),
that then applies them to the underlying thing?

I also like partial function application. What is the easiest way of
achieving this in Python? Would it look something like this:

def foo(x, y):
    return x + y

xFoo = lambda y: foo(10, y)



More information about the Python-list mailing list