Ah, true, however, I still get the same error.<br><br>
<div class="gmail_quote">2008/7/8 Dan Eloff &lt;<a href="mailto:dan.eloff@gmail.com">dan.eloff@gmail.com</a>&gt;:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi,<br><br>exec is not a function, it&#39;s a statement.<br><br>exec moduleSource in newModule.__dict__<br>
<br>-Dan<br>
<div>
<div></div>
<div class="Wj3C7c"><br>On Tue, Jul 8, 2008 at 6:40 AM, TraumaPony &lt;<a href="mailto:pontheangelofdeath@gmail.com">pontheangelofdeath@gmail.com</a>&gt; wrote:<br>&gt; Hi, I have two questions regarding the IronPython 2.0 B3.<br>
&gt;<br>&gt; 1. I&#39;m trying to expose only a few methods from my assembly, but I haven&#39;t<br>&gt; the faintest idea how to do it. The best I can come up with is the<br>&gt; following:<br>&gt;<br>&gt; import clr<br>&gt; clr.AddReference(&quot;CoolEngine&quot;)<br>
&gt; def randomIntNoParams():<br>&gt; &nbsp; &nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>&gt; &nbsp; &nbsp; return CoolEngine.Engine.Scripting.ScriptManager.RandomInt()<br>&gt; def randomIntOneParam(i):<br>&gt; &nbsp; &nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>
&gt; &nbsp; &nbsp; return CoolEngine.Engine.Scripting.ScriptManager.RandomInt(i)<br>&gt; def randomIntTwoParams(i, j):<br>&gt; &nbsp; &nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>&gt; &nbsp; &nbsp; return CoolEngine.Engine.Scripting.ScriptManager.RandomInt(i, j)<br>
&gt; def randomIntThreeParams(i, j, k):<br>&gt; &nbsp; &nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>&gt; &nbsp; &nbsp; return CoolEngine.Engine.Scripting.ScriptManager.RandomInt(i, j, k)<br>&gt; def randomIntThreeParamsNoReturn(i, j, k):<br>
&gt; &nbsp; &nbsp; from CoolEngine.Engine.Scripting import ScriptManager<br>&gt; &nbsp; &nbsp; CoolEngine.Engine.Scripting.ScriptManager.RandomIntNoReturn(i, j, k)<br>&gt; But alas, it says &quot;name &#39;CoolEngine&#39; is not defined&quot; . What am I doing wrong<br>
&gt; there?<br>&gt;<br>&gt; 2. I&#39;m trying to create a module dynamically at runtime. I have the<br>&gt; following code which I want to be placed in a module called &quot;Script&quot;:<br>&gt;<br>&gt; import clr<br>&gt; clr.AddReference(&quot;System.Threading&quot;)<br>
&gt; def Pause(milliseconds):<br>&gt; &nbsp; &nbsp; from System.Threading.Tasks import Task<br>&gt; &nbsp; &nbsp; Task.CurrentTask.Wait(milliseconds)<br>&gt;<br>&gt; However, I have no idea how to get it into its own module from there, and<br>
&gt; including it in its own file called Script.py is out of the question; I have<br>&gt; that code as a string resource in my assembly.<br>&gt;<br>&gt; I&#39;m doing the following:<br>&gt;<br>&gt; Engine.CreateScriptSourceFromString(<br>
&gt;<br>&gt; &quot;import imp\n&quot;<br>&gt;<br>&gt; +<br>&gt;<br>&gt; &quot;import sys\n&quot;<br>&gt;<br>&gt; +<br>&gt;<br>&gt; &quot;newModule = imp.new_module(moduleName)\n&quot;<br>&gt;<br>&gt; +<br>&gt;<br>&gt; &quot;exec(moduleSource, newModule.__dict__)\n&quot;<br>
&gt;<br>&gt; +<br>&gt;<br>&gt; &quot;sys.modules[moduleName] = newModule&quot;<br>&gt;<br>&gt; , SourceCodeKind.Statements).Execute(scope);<br>&gt;<br>&gt; where the moduleName variable is &quot;Script&quot; and the moduleSource is the above<br>
&gt; source code. However, I get the following message:<br>&gt;<br>&gt; An unhandled exception of type &#39;Microsoft.Scripting.SyntaxErrorException&#39;<br>&gt; occurred in Unknown Module.<br>&gt;<br>&gt; Additional information: unexpected token &#39;\r&#39;<br>
&gt;<br>&gt; Any ideas?<br>&gt;<br>&gt;<br>&gt;<br>&gt; --<br>&gt; /&quot;\<br>&gt; \ / ASCII RIBBON CAMPAIGN<br>&gt; X AGAINST HTML MAIL<br>&gt; / \<br>&gt;<br>&gt; This message has been encrypted with ROT-26. Any unauthorised decryption<br>
&gt; will result in prosecution to the full extent of the law.<br>&gt;<br></div></div>&gt; _______________________________________________<br>&gt; Users mailing list<br>&gt; <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
&gt; <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>&gt;<br>&gt;<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><br clear="all"><br>-- <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.