[IronPython] unexpected token print at <string>:1

Szymon Kobalczyk s.kobalczyk at softwaremind.pl
Fri Mar 3 23:02:24 CET 2006


JoeSox napisał(a):
> Ok, so my next question is
>
> global_eng.Execute("print \"hello\"");
>
> does not return a Stmt.  How do I access it's value?
> If I am not mistaken, the return statement is held in the Stmt's value.
>
>   
In Python the value of last statement is stored in special '_' variable. 
So to read it just use:

engine.GetVariable("_");

Note that if you precompile your scripts you must set the last argument 
of Compile method to true in order for this to work:

engine.Compile(script, true);

Hope this helps,
Szymon Kobalczyk
www.geekswithblogs.net/kobush





More information about the Ironpython-users mailing list