Modifying func_closure

Jacek Generowicz jacek.generowicz at cern.ch
Thu Jul 8 14:24:10 EDT 2004


On 8 Jul 2004, at 18:38, Robert Brewer wrote:

> Jacek Generowicz wrote:
>> Python's closures are read-only. But is there a way of hacking one's
>> way around this restriction?

> If I understand your requirements correctly, I would use 
> new.function(),
> passing it the closure you want.
>
> return new.function(co, f.func_globals, newname, f.func_defaults,
> f.func_closure)

But this doesn't help me to modify the binding in an original closure 
... unless I'm missing your point.




More information about the Python-list mailing list