Closures and Partial Function Application

Travis Parks jehugaleahsa at gmail.com
Wed Aug 31 19:51:37 CEST 2011


On Aug 31, 1:18 pm, Chris Rebert <c... at rebertia.com> wrote:
> On Wed, Aug 31, 2011 at 9:45 AM, Travis Parks <jehugalea... 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.
>
> Assuming I'm intuiting your question correctly, then you're incorrect;
> they are "read/write". You just need a `nonlocal` declaration for the
> variables in question. Seehttp://www.python.org/dev/peps/pep-3104/
> andhttp://docs.python.org/release/3.1.3/reference/simple_stmts.html#nonl...
> for details.
>
> Cheers,
> Chris
>
>

Cool. So I just need to put "nonlocal" in front of the variable name.



More information about the Python-list mailing list