Closures
Gustavo Niemeyer
niemeyer at conectiva.com
Sat May 1 16:35:25 EDT 2004
> > class Closure:
> > def __init__(self):
> > self.__dict__ = sys._getframe().f_back.f_locals
>
> Out of interest how portable is this? Strikes me as extremely useful
> class to have lying around :) The only thing that makes me wonder is
> the access to _getframe...
I'd put it in the "hack" section. :-)
As others have said, you may pass a locals() parameter to the class
if you want to be in the safe side.
But-it-wont-be-so-fun-ly y'rs
--
Gustavo Niemeyer
http://niemeyer.net
More information about the Python-list
mailing list