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