Re: Possible to reach back in stack and grab calling function's locals()?

2010-06-18 Thread python
Ryan, Thank you very much - your example is exactly the technique I was looking for. My use case is unusual and we don't need to update the parent's version of locals(). The code in question is an internal template library whose methods need access to their caller's locals() so they can figure

Possible to reach back in stack and grab calling function's locals()?

2010-06-17 Thread python
Is there an elegant way to reach back in the stack and grab the calling function's copy of locals()? I'm working on a library that does lots of textmerge operations and am looking for a way to eliminate the need for many of the calls to our library to have to explictly pass locals() to our

Re: Possible to reach back in stack and grab calling function's locals()?

2010-06-17 Thread Ryan Kelly
On Thu, 2010-06-17 at 16:02 -0400, pyt...@bdurham.com wrote: Is there an elegant way to reach back in the stack and grab the calling function's copy of locals()? You can do it using my favourite function, sys._getframe: import sys def outer(): ... a = 1 ... inner() ... def