[Eric] Importing files located in other directories: what's the best approach?

Geert Vancompernolle geert.eric4 at gmail.com
Mon Jan 19 18:53:59 GMT 2009


Hi,

Suppose I have the following hypothetical directory structure:

./projects/myproject/main.py
                    /ui/mainDlg.py
                    /ui/mainDlg1.py
                    /ui/mainDlg2.py
                    /data/mainData.py

Now, suppose ./ui/mainDlg.py depends on ./ui/mainDlg1.py, 
./ui/mainDlg2.py and ./data/mainData.py.
Also, suppose ./main.py depends on ./ui/mainDlg.py (and so, indirectly 
depends on the other files), what's the best approach to import these 
files in their respective dependent file?

There might be different solutions, like extending the sys.path variable 
or working with __init__.py files in the corresponding (sub)directories, 
but I guess there should be one nice approach to solve such issues.

Any suggestions?

-- 
Best rgds,

Geert
________________________________________________

*Use EcoCho <http://www.ecocho.com>: environmentally friendly search the 
internet!*



More information about the Eric mailing list