On Jan 25, 1:05 am, Steven D'Aprano <ste...@remove.this.cybersource.com.au> wrote: > On Sun, 24 Jan 2010 10:11:07 -0800, George Sakkis wrote: > > Both in your example and by using a context manager, you can get away > > with not passing locals() explicitly by introspecting the stack frame. > > You say that as if it were less of an ugly hack than the locals() trick. > But sys._getframe is a private implementation detail, so you're no better > off.
The client *is* better off in that he doesn't have to pass locals() to some magic decorator to achieve his goal; how this is implemented is a different issue. As for being an ugly hack, you may use inspect.stack () if the underscore in sys._getframe() makes you feel dirty. George -- http://mail.python.org/mailman/listinfo/python-list