On 23 Mar 2005 10:13:16 GMT, Duncan Booth <[EMAIL PROTECTED]> wrote: >Do I really need to mention that the whole concept here is broken. This >only works if you call it from global scope. If you call it from inside a >function it [usually] won't work:
Ok... you can get globals this way if you know how many frames up it is. Not terrable useful. :/ def frame0(): print 'frame0 (locals): ',sys._getframe(0).f_locals print '\nframe1 (parent): ',sys._getframe(1).f_locals print '\n(Global) : ',sys._getframe(2).f_locals def frame1(): frame0() import sys frame1() >>> frame0 (locals): {} frame1 (parent): {} (Global) : {'__builtins__': <module '__builtin__' (built-in)>, 'sys': <module 'sys' (built-in)>, '__name__': '__main__', 'frame1': <function frame1 at 0x00B437B0>, 'frame0': <function frame0 at 0x00B43770>, '__doc__': None} >>> -- http://mail.python.org/mailman/listinfo/python-list