[IronPython] IP 2 Hosting
Curt Hagenlocher
curt at hagenlocher.org
Sat Mar 29 19:21:10 CET 2008
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
More information about the Ironpython-users
mailing list