2024-06-16 17:08:59 发布
网友
使用C中设置的python脚本引擎#使用IronPython,是否有方法从python代码中检索当前正在执行的函数?你知道吗
例如,在我的代码中,setuppython脚本引擎存储在变量pse中。是否有类似于pse.GetVariables()的调用返回当前正在执行的python函数?你知道吗
pse
pse.GetVariables()
例如,我希望能够提取这些信息,以便在测试的检查中使用。你知道吗
你可以使用跟踪功能。设置将为执行脚本的每一行调用的跟踪回调。从该回调中,可以获得当前正在执行的函数名。你知道吗
pse.SetTrace(IronPythonTraceCallbaback);
以及回调定义:
static TracebackDelegate IronPythonTraceBack(TraceBackFrame frame, string result, object payload) { if (frame != null && frame.f_code != null) { // Here you can access the executing function information FunctionCode functionCode = frame.f_code; string functionName = frame.f_code.co_name; } return IronPythonTraceBack; }
你可以使用跟踪功能。设置将为执行脚本的每一行调用的跟踪回调。从该回调中,可以获得当前正在执行的函数名。你知道吗
以及回调定义:
相关问题 更多 >
编程相关推荐