I've just started to learn IronPython and I tried the code below which returned IronPython.Runtime.UnboundNameException: 'name 'hello' is not defined'.
Code:
var py = Python.CreateEngine();
var scope = py.CreateScope();
py.Execute(@"word = input('Input string\n')", scope);
var input = scope.GetVariable("word");
py.Execute("print " + input);
Console run ok, then it asked me to Input string, and I typed into "hello". And then it fired off the above error message. Then I tried this one just to see if it does without input method:
py.Execute(@"x = 2 + 3", scope);
py.Execute("print 'result'," + scope.GetVariable("x"));
So that one was ok.
Can someone please explain why can I not retrieve a variable from "input" method? and why is it an UnboundNameException?
Many thanks!
raw_input, notinput.wroda typo here:var input = scope.GetVariable("wrod");raw_inputand now it returnsIronPython.Runtime.UnboundNameException: 'global name 'hello' is not defined'. But now this error is at the line whereprintmethod is.