getting caller

Hamish McKenzie hamish at valvesoftware.com
Thu Feb 12 16:26:26 EST 2009


so I'm trying to wrap some functionality around execfile but don't want to modify the way it works.  specifically when you call execfile, it automatically grabs globals and locals from the frame the execfile exists in.

so if I wrap execfile in a function, I need a way to reliably get at the calling frame.

what I want to know is - is it *ALWAYS* true that:
inspect.getouterframes( inspect.currentframe() )[ 1 ][ 0 ]

will return me the frame that called execfile in the first place?

I can't think of a way that this wouldn't be the case, but I'm not 100% sure that assertion is valid.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090212/1d182359/attachment.html>


More information about the Python-list mailing list