I expect you could combine the following with decorators as an easy way to grab a function's locals just before it exits... you could also use exec or eval to execute code in the function's local namespace. ---------------------------------------
# Try it: def trace_returns(frame, event, arg): if event == 'return': print "[frame locals just before return: %s]" % frame.f_locals return trace_returns def foo(a, b): return a + b import sys sys.settrace(trace_returns) foo(1,2) -- http://mail.python.org/mailman/listinfo/python-list