private ScriptEngine pe;
private ScriptScope scope;
private void button1_Click(object sender, EventArgs e)
{
pe = Python.CreateEngine();
scope = pe.CreateScope();
pe.Runtime.SetTrace(OnTraceback);
pe.Execute(@"
def square(x):
s = x*x
return s
a = square(2) + (3)
print ""hello world "" + str(a)
", scope);
}
private TracebackDelegate OnTraceback(TraceBackFrame frame, string result, object payload)
{
//How can I access the local variables of the current function?
return OnTraceback;
}
Let me repeat: I want to get the local variables of the function, where the python execution currently is (the function surrounding line frame.f_lineno
).