<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Nov 24, 2014, at 6:12 AM, Ian Kelly <<a href="mailto:ian.g.kelly@gmail.com" class="">ian.g.kelly@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><p dir="ltr" class=""><br class="">
On Nov 24, 2014 1:27 AM, "Patrick Stinson" <<a href="mailto:patrickkidd@gmail.com" class="">patrickkidd@gmail.com</a>> wrote:<br class="">
><br class="">
> How does the __del__ method have a reference to the module’s globals dict? because it references the print function?</p><p dir="ltr" class="">The module's dict becomes the __globals__ dict used by the function for looking up globals and builtins.<br class=""></p></div></blockquote><div>Wow, that’s very helpful and good to know. Funny I never ran into that when doing this via an extensive CPython embedding project. Or maybe I ignored it.</div><blockquote type="cite" class=""><div class=""><p dir="ltr" class="">> Crazy. Is there any other way to comfort when a module is being deleted beside defining a class object with a printing dtor?</p><p dir="ltr" class="">Modules don't strictly have to be ModuleType. You could substitute a class with a __del__ method for the module itself for testing this. Be careful with leaving this in your production code though, as the presence of __del__ methods can interfere with garbage collection and are not advisable prior to 3.4.</p><p dir="ltr" class="">You can also test whether an object is still in memory by looking for it in gc.get_objects() although be warned that is an expensive call.<br class=""></p></div></blockquote><div>Interesting concept. One thing I am doing is allowing one script to import another by name. So in my gui I’ll have a panel for each script with a line edit to set the name, which then generates an appropriate slug. Is it still possible to import non-module objects? I guess this question is just for fun now :)</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><p dir="ltr" class="">
</p>
-- <br class=""><a href="https://mail.python.org/mailman/listinfo/python-list" class="">https://mail.python.org/mailman/listinfo/python-list</a><br class=""></div></blockquote></div><br class=""></body></html>