Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=7181648 By: fabioz
Usually when I have a function I need to be present for all underneath modules, that function is defined in the root of the module structure (in the __init__.py). E.g.: Suppose you have the following package structure: main.py root ....__init__.py ....real_main.py ....leaf ........__init__.py ........leaf2.py If you define the function you need in root/__init__.py, that function will automatically be defined at the time it is imported (and whenever any of those subpackages is also imported, as doing any import from a subpackage will trigger the import of its parent package first). So, the main.py should simple import root.real_main and that code is the one that should really have the code (even if the main.py is the entry point of your application). Note that this is also needed to properly unit-test your application (because as you noted, that function won't be available unless your main module is actually run... which is not the case on unit-tests) Cheers, Fabio ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=293649 ------------------------------------------------------------------------------ This SF.net email is sponsored by: High Quality Requirements in a Collaborative Environment. Download a free trial of Rational Requirements Composer Now! http://p.sf.net/sfu/www-ibm-com _______________________________________________ Pydev-users mailing list Pydev-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pydev-users