[IronPython] How to load built-in models.

Michael Foord fuzzyman at voidspace.org.uk
Sun Jul 13 03:33:09 PDT 2008


Han Kejing wrote:
>
> Hi, all,
>
> I was write follows code in my WinForm application. But I got an 
> SyntaxErrorException “unexpected token 'print'”.
>
> ScriptRuntimeSetup runtimeSetup = new ScriptRuntimeSetup(true);
>
> this._runtime = ScriptRuntime.Create(runtimeSetup);
>
> this._engine = this._runtime.GetEngine(typeof(PythonContext));
>
> this._scope = this._engine.CreateScope();
>
> _engine.CreateScriptSourceFromString("print(\"test\")").Execute(_scope);
>

That last line should be:

_engine.CreateScriptSourceFromString("print(\"test\")", 
SourceCodeKind.Statements).Execute(_scope);

Michael

> I think maybe the built-ins modules is not loaded in my code.
>
> How to load it? Thanks.
>
> ----------------------------------------------------------------
>
> Do ONE thing, and do it WELL.
>
> Colin Han/ @/ *GrapeCity*
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.theotherdelia.co.uk/
http://www.resolverhacks.net/



More information about the Users mailing list