Greetings,<br><br>I am trying to create built-in sub modules..&nbsp; I have read everything I can on this subject..<br>And I&#39;ve tried many many possible solutions..&nbsp;&nbsp; And lost many hours actually (blech).&nbsp; <br><br>Some of the e-mails in these newsgroups from long ago are quite misleading..&nbsp; Other e-mails on this topic seem to be inaccessible.&nbsp; Much of &quot;piper-mail&quot; is gone it seems, or relocated beyond the reach of google. (didn&#39;t know that was still possible!)<br>
<br>The only solution that works so far:<br><br>given that I&#39;ve created dD_script and dD_object and dD* modules previously..<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object dD = object(handle&lt;&gt;(PyImport_AddModule (&quot;dD&quot;)));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; char *statement = <br>
<br>// import what I need, I guess I don&#39;t need types actually<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;import sys, types\n&quot;\<br><br>// this is importing all of the modules that I&#39;ve already created..<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;import dD, dD_script, dD_object, dD_types, dD_ui, dD_device, dD_render, dD_internal\n&quot;\<br>
<br>// this is assigning them to the parent &quot;package&quot;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;dD.Script = sys.modules[&#39;dD.Script&#39;] = dD_script\n&quot;\<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;dD.Object = sys.modules[&#39;dD.Object&#39;] = dD_object\n&quot;\<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;dD.Types = sys.modules[&#39;dD.Types&#39;] = dD_types\n&quot;\<br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;dD.UI = sys.modules[&#39;dD.UI&#39;] = dD_ui\n&quot;\<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;dD.Device = sys.modules[&#39;dD.Device&#39;] = dD_device\n&quot;\<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;dD.Render = sys.modules[&#39;dD.Render&#39;] = dD_render\n&quot;\<br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &quot;dD.Internal = sys.modules[&#39;dD.Internal&#39;] = dD_internal&quot;\<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ;<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; exec(statement, mainDict, mainDict);<br><br><br>The non-solutions that don&#39;t work:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object dD = object(handle&lt;&gt;(PyImport_AddModule (&quot;dD&quot;)));<br>
<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dD.attr(&quot;Script&quot;) = handle&lt;&gt;(PyImport_ImportModule(&quot;dD_script&quot;));<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dD.attr(&quot;Object&quot;) = handle&lt;&gt;(PyImport_ImportModule(&quot;dD_object&quot;));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dD.attr(&quot;Types&quot;) = handle&lt;&gt;(PyImport_ImportModule(&quot;dD_types&quot;));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dD.attr(&quot;UI&quot;) = handle&lt;&gt;(PyImport_ImportModule(&quot;dD_ui&quot;));<br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dD.attr(&quot;Device&quot;) = handle&lt;&gt;(PyImport_ImportModule(&quot;dD_device&quot;));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dD.attr(&quot;Render&quot;) = handle&lt;&gt;(PyImport_ImportModule(&quot;dD_render&quot;));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dD.attr(&quot;Internal&quot;) = handle&lt;&gt;(PyImport_ImportModule(&quot;dD_internal&quot;));<br>

<br>&nbsp; I also tried manipulating the dictionary of the dD module instead of attributes above<br><br><br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; object sys = import(&quot;sys&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dict sysDict (sys.attr(&quot;__dict__&quot;));<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysDict[&quot;dD.Script&quot;] = dD[&quot;Script&quot;];<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysDict[&quot;dD.Object&quot;] = dD[&quot;Object&quot;];<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysDict[&quot;dD.Types&quot;] = dD[&quot;Types&quot;];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysDict[&quot;dD.UI&quot;] = dD[&quot;UI&quot;];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysDict[&quot;dD.Device&quot;] = dD[&quot;Device&quot;];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysDict[&quot;dD.Render&quot;] = dD[&quot;Render&quot;];<br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysDict[&quot;dD.Internal&quot;] = dD[&quot;Internal&quot;];<br><br>well if dD is the object these direct [] indexes fail, if it is a dict, the solution still doesn&#39;t work<br><br><br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; dict sysModules (sys.attr(&quot;modules&quot;));<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysModules[&quot;dD.Script&quot;] = dD.attr(&quot;Script&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysModules[&quot;dD.Object&quot;] = dD.attr(&quot;Object&quot;);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysModules[&quot;dD.Types&quot;] = dD.attr(&quot;Types&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysModules[&quot;dD.UI&quot;] = dD.attr(&quot;UI&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysModules[&quot;dD.Device&quot;] = dD.attr(&quot;Device&quot;);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysModules[&quot;dD.Render&quot;] = dD.attr(&quot;Render&quot;);<br>

&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sysModules[&quot;dD.Internal&quot;] = dD.attr(&quot;Internal&quot;);<br><br>if I do dict stuff instead of attribute, still doesn&#39;t work..<br><br>===================<br><br>Is there a better way for me to do this, than executing the python code segment?<br>
Does anyone know what is going on behind the scenes in the python code execution?<br><br>Thanks,<br><br>-tim<br>