<div dir="ltr">Howdy again,<br><br>According to the hosting spec each language defines how, and what, to return at the end of a script when using Execute&lt;T&gt;, is there a way to do this on IronPython? I&#39;ve tried a couple of things, such as<br>
<br>from Dirt import *<br><br>def echo(x):<br>&nbsp;&nbsp;&nbsp; return x<br>&nbsp;&nbsp;&nbsp; <br>kitty = Cat()<br>kitty.Name = &quot;Tito&quot;<br>kitty.Meow()<br>kitty<br><br>As an alternative, I&#39;m using the following with the above Python code.<br>
<br>&nbsp;public static T GetObject&lt;T&gt;(string fileName, string objectName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string path = String.Format(&quot;{0}{1}{2}.py&quot;, BaseDir, @&quot;\HostScripts\&quot;, fileName);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ScriptSource source = privateEngine.CreateScriptSourceFromFile(path);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; source.Execute();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return privateEngine.GetVariable&lt;T&gt;(privateEngine.GetScope(path), objectName);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>//catches ommitted for space<br>}<br><br>Cat tito = DynamicServices.GetObject&lt;Cat&gt;(&quot;MUDConfig&quot;, &quot;kitty&quot;);<br>Console.WriteLine(tito.Name);<br><br>I&#39;d like to load my configuration files\classes and handle &#39;serialization&#39; via Python scripts, for various reasons, and using Execute would prevent me from having to pick and choose specific names. (I.E. Kitty - since that would be hardcoded in the C# source)<br>
<br>---<br>V<br></div>