Closures and Partial Function Application
Arnaud Delobelle
arnodel at gmail.com
Wed Aug 31 12:55:34 EDT 2011
On 31 August 2011 17:45, Travis Parks <jehugaleahsa at gmail.com> wrote:
> 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 don't understand. Can you give an example?
> 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)
from functools import partial
foo10 = partial(foo, 10)
HTH
Arnaud
More information about the Python-list
mailing list