<div>Hi, I have two questions regarding the IronPython 2.0 B3.</div>
<div>&nbsp;</div>
<div>1. I&#39;m trying to expose only a few methods from my assembly, but I haven&#39;t the faintest idea how to do it. The best I can come up with is the following:</div>
<div>&nbsp;</div>
<div>import clr<br>clr.AddReference(&quot;CoolEngine&quot;)<br>def randomIntNoParams():<br>&nbsp;&nbsp;&nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>&nbsp;&nbsp;&nbsp; return CoolEngine.Engine.Scripting.ScriptManager.RandomInt()<br>
def randomIntOneParam(i):<br>&nbsp;&nbsp;&nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>&nbsp;&nbsp;&nbsp; return CoolEngine.Engine.Scripting.ScriptManager.RandomInt(i)<br>def randomIntTwoParams(i, j):<br>&nbsp;&nbsp;&nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>
&nbsp;&nbsp;&nbsp; return CoolEngine.Engine.Scripting.ScriptManager.RandomInt(i, j)<br>def randomIntThreeParams(i, j, k):<br>&nbsp;&nbsp;&nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>&nbsp;&nbsp;&nbsp; return CoolEngine.Engine.Scripting.ScriptManager.RandomInt(i, j, k)<br>
def randomIntThreeParamsNoReturn(i, j, k):<br>&nbsp;&nbsp;&nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>&nbsp;&nbsp;&nbsp; CoolEngine.Engine.Scripting.ScriptManager.RandomIntNoReturn(i, j, k)</div>
<div><br>But alas, it says <font size="1">&quot;name &#39;CoolEngine&#39; is not defined&quot;&nbsp;. </font>What am I doing wrong there?</div>
<div>&nbsp;</div>
<div>2. I&#39;m trying to create a module dynamically at runtime. I have the following code which I want to be placed in a module called &quot;Script&quot;:</div>
<div>&nbsp;</div>
<div>import clr<br>clr.AddReference(&quot;System.Threading&quot;)<br>def Pause(milliseconds):<br>&nbsp;&nbsp;&nbsp; from System.Threading.Tasks import Task<br>&nbsp;&nbsp;&nbsp; Task.CurrentTask.Wait(milliseconds)</div>
<div>
<p>However, I have no idea how to get it into its own module from there, and including it in its own file called Script.py is out of the question; I have that code as&nbsp;a string resource in my assembly. </p>
<p>I&#39;m doing the following:</p><b><font size="2">
<p>Engine.CreateScriptSourceFromString(</p></font><font color="#a31515" size="2"><font color="#a31515" size="2">
<p>&quot;import imp\n&quot;</p></font></font><font size="2">+</font><font color="#a31515" size="2"><font color="#a31515" size="2">
<p>&quot;import sys\n&quot;</p></font></font><font size="2">+</font><font color="#a31515" size="2"><font color="#a31515" size="2">
<p>&quot;newModule = imp.new_module(moduleName)\n&quot;</p></font></font><font size="2">+</font><font color="#a31515" size="2"><font color="#a31515" size="2">
<p>&quot;exec(moduleSource, newModule.__dict__)\n&quot;</p></font></font><font size="2"> +</font><font color="#a31515" size="2"><font color="#a31515" size="2">
<p>&quot;sys.modules[moduleName] = newModule&quot;</p></font></font><font size="2">, </font></b><font color="#2b91af" size="2"><font color="#2b91af" size="2">SourceCodeKind</font></font><b><font size="2">.Statements).Execute(scope);</font></b>
<p>where the moduleName variable is &quot;Script&quot; and the moduleSource is the above source code. However, I get the following message:</p>
<p>An unhandled exception of type &#39;Microsoft.Scripting.SyntaxErrorException&#39; occurred in Unknown Module.</p>
<p>Additional information: unexpected token &#39;\r&#39;</p>
<p>Any ideas?</p>
<p>&nbsp;</p>
<p>-- <br>/&quot;\<br>\ / ASCII RIBBON CAMPAIGN<br>X AGAINST HTML MAIL<br>/ \<br><br>This message has been encrypted with ROT-26. Any unauthorised decryption will result in prosecution to the full extent of the law. </p>
</div>