Some of those look like names from A9, which have changed in B1.

The easiest way to evaluate an expression from scratch seems to be as
follows:

    ScriptEngine engine = ScriptRuntime.Create().GetEngine("py");
    ScriptScope scope = engine.CreateScope();
    ScriptSource source = engine.CreateScriptSourceFromString("1 + 1",
SourceCodeKind.Expression);
    int result = source.Execute<int>(scope);

On Sat, Mar 29, 2008 at 10:00 AM, Michael Foord <[EMAIL PROTECTED]>
wrote:

> Hello guys,
>
> I'm trying to do some simple examples of hosting with IronPython 2. Boy
> you made things more complicated than IronPython 1. :-)
>
> Unfortunately the DLR hosting spec document is out of date. I have a
> couple of questions (but will keep exploring).
>
> The simplest use case is just to evaluate an expression and return a
> result.
>
> The hosting spec document mention 'ScriptRuntime.Execute(text)'. This
> may or may not be the right way to evaluate an expression, but in any
> case it has been removed.
>
> An alternative is:
>
>    engine = PythonEngine.CurrentEngine # a ScriptEngine
>    unit = engine.CreateSourceUnitFromString(code, id)
>    result = unit.Execute()
>
> Which is straightforward enough, however I can't see a way to set
> TrueDivision using this technique.  (What is the 'id' by the way?)
>
> I can see that TrueDivision is a setting on
> IronPython.Runtime.ModuleOptions and IronPython.Runtime.PythonModule.
> Can I set this on the engine somehow?
>
> All the alternative seem to lead down a rabbit warren of 'create this
> object - which requires this object - which you construct from another
> object - which...'. I don't know which path to follow down the rabbit
> hole...
>
> :-)
>
> Any suggestions to save me from madness?
>
> Michael
> _______________________________________________
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to