<div>Some of those look like names from A9, which have changed in B1.</div>
<div>&nbsp;</div>
<div>The easiest way to evaluate an expression from scratch seems to be as follows:</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp;&nbsp; ScriptEngine engine = ScriptRuntime.Create().GetEngine(&quot;py&quot;);<br>&nbsp;&nbsp;&nbsp; ScriptScope scope = engine.CreateScope();<br>&nbsp;&nbsp;&nbsp; ScriptSource source = engine.CreateScriptSourceFromString(&quot;1 + 1&quot;, SourceCodeKind.Expression);<br>
&nbsp;&nbsp;&nbsp; int result = source.Execute&lt;int&gt;(scope);<br></div>
<div><br></div>
<div class="gmail_quote">On Sat, Mar 29, 2008 at 10:00 AM, Michael Foord &lt;<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hello guys,<br><br>I&#39;m trying to do some simple examples of hosting with IronPython 2. Boy<br>you made things more complicated than IronPython 1. :-)<br>
<br>Unfortunately the DLR hosting spec document is out of date. I have a<br>couple of questions (but will keep exploring).<br><br>The simplest use case is just to evaluate an expression and return a result.<br><br>The hosting spec document mention &#39;ScriptRuntime.Execute(text)&#39;. This<br>
may or may not be the right way to evaluate an expression, but in any<br>case it has been removed.<br><br>An alternative is:<br><br>&nbsp; &nbsp;engine = PythonEngine.CurrentEngine # a ScriptEngine<br>&nbsp; &nbsp;unit = engine.CreateSourceUnitFromString(code, id)<br>
&nbsp; &nbsp;result = unit.Execute()<br><br>Which is straightforward enough, however I can&#39;t see a way to set<br>TrueDivision using this technique. &nbsp;(What is the &#39;id&#39; by the way?)<br><br>I can see that TrueDivision is a setting on<br>
IronPython.Runtime.ModuleOptions and IronPython.Runtime.PythonModule.<br>Can I set this on the engine somehow?<br><br>All the alternative seem to lead down a rabbit warren of &#39;create this<br>object - which requires this object - which you construct from another<br>
object - which...&#39;. I don&#39;t know which path to follow down the rabbit<br>hole...<br><br>:-)<br><br>Any suggestions to save me from madness?<br><br>Michael<br>_______________________________________________<br>Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</blockquote></div><br>