2006-03-12

ASPN : Python Cookbook : neat notation for python closures

Got this through the Daily-Python-URL . Rather cool way to get mutable cell variables by assigning to an attribute of the returned enclosed function.

On c.l.py there was someone asking how to get access to the function object from within the function without knowing its name. Currently there is no way without doing introspection on the execution frame, but if we could come up with a decent way of doing it might help facilitate stuff like this.But then again there has been talk of making cell variables mutable anyway, and thus the trick of using a mutable object like a list in a cell variable would become moot.

Read more at aspn.activestate.com/AS...