Modifying func_closure
Robert Brewer
fumanchu at amor.org
Fri Jul 9 18:01:35 EDT 2004
Jacek Generowicz wrote:
> Sent: Friday, July 09, 2004 2:58 PM
> To: Robert Brewer
> Subject: Re: Modifying func_closure
>
>
>
> On 9 Jul 2004, at 23:13, Robert Brewer wrote:
>
> > def closures():
> > enclosed = [1]
> > def report():
> > return enclosed[0]
> > def modify(new):
> > enclosed[0] = new
> > return enclosed[0]
> > return report, modify
>
> Sorry, I should have mentioned that I am fully aware of this approach.
I figured you were... ;)
I don't think there's any way from inside modify() to change the
closure. If you're still considering new.function() in any way, you
might be able to fake cell modification with something like:
def make_closure(*args):
def inner():
args
return inner.func_closure
Good luck!
Bob
More information about the Python-list
mailing list