【发布时间】:2012-03-04 05:24:45
【问题描述】:
我正在编写一个调试器,我需要访问以前调用的框架的局部变量
例如,我有这样的代码:
def foo():
...
result = bar(args) # bar is some function
locals_of_bar = ...#get the locals() dict of the frame in which `bar` was called
编辑:为了更清楚,我更新了问题。
【问题讨论】:
-
函数没有本地人。栈帧(具体函数调用)有。
-
您的问题在技术上似乎不正确,因为它适用于堆栈调用,并且在调用和从方法返回时创建和销毁局部变量。