问题描述
我正在尝试获取调用方表达式的ast,但是对于多行表达式,框架的索引/行号似乎不正确。
class Foo:
def fun(self,arg):
stack = inspect.stack(100)
frame = stack[1]
f = Foo()
# This works fine
ast = f.fun(1)
# For some reason,the frame's index is pointing to the "+2" line instead of the closing ")" line
# I am hoping to capture the expression that makes the 'fun' function call
ast = f.fun(1
+ 2
)
感谢对此的任何帮助或思考,或如何处理多行代码框架。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)