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;
}
ฉันขอย้ำอีกครั้ง: ฉันต้องการรับตัวแปรในเครื่องของฟังก์ชัน ซึ่งการดำเนินการของ Python อยู่ในขณะนี้ (ฟังก์ชันที่อยู่รอบบรรทัด frame.f_lineno
)