[IronPython] IP 2 Hosting

Michael Foord fuzzyman at voidspace.org.uk
Sat Mar 29 20:06:53 CET 2008


            
((IronPython.PythonEngineOptions)engine.Options).DivisionOptions = 
IronPython.PythonDivisionOptions.New;

This worked!

Thanks - it is for a simple embedding example which is a calculator. The 
winforms UI builds up expressions and the '=' button evaluates them with 
the Python engine. :-)

Michael


Curt Hagenlocher wrote:
> On Sat, Mar 29, 2008 at 10:51 AM, Michael Foord
> <fuzzyman at voidspace.org.uk> wrote:
>   
>> Cool - I was just being rude.
>>     
>
> Hey, I feel your pain!  I'd swear that I've rewritten more hosting
> code than I've written...
>
>   
>> Any ideas on switching on TrueDivision for the scope?
>>     
>
> This is what I was able to puzzle out.  I have no idea how "correct" it is.
>     ScriptSource source = engine.CreateScriptSourceFromString("import
> foo", SourceCodeKind.Statements);
>     ScriptScope scriptScope = runtime.ExecuteSourceUnit(source);
>     Scope scope = scriptScope.GetVariable<Scope>("foo");
>     PythonModule extension =
> (PythonModule)scope.GetExtension(scope.Language.ContextId);
>     extension.TrueDivision = true;
>
> It looks like you can set this globally by doing something like this:
> ((IronPython.PythonEngineOptions)engine.Options).DivisionOptions =
> IronPython.PythonDivisionOptions.New;
>
> --
> Curt Hagenlocher
> curt at hagenlocher.org
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   




More information about the Ironpython-users mailing list