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

python at bdurham.com python at bdurham.com
Fri Jun 18 14:12:21 EDT 2010


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 out how to expand
variable references in string expressions. Eventually this library will
be replaced with a more conventional template package; however, for the
moment, I'm just keeping what we currently have working smoothly :)

Cheers,
Malcolm



More information about the Python-list mailing list