[Chicago] import question

Massimo Di Pierro mdipierro at cs.depaul.edu
Tue Jan 22 22:59:10 CET 2008


Hello everybody,

I was hoping you could help me.

Say I have a module called test

test/
    __init__.py
    other.py

and __init__.py says

    from test.other import something

so that I can

    from test import something

Now I do not want to install the module but I want to place it under  
a folder called contrib:

contrib/
    test/
       __init__.py
       other.py

and I want to be able to say

   from contrib.test import something

Now __init__ fails to find test.other because that's contrib.test.other.

Two natural solutions are:
1) edit __init__.py and replace test.other with write  
contrib.test.other. This is not acceptable for me since I do not want  
to maintain the test module.
2) add contrib to the path. This is also not acceptable because  
creates countless problems with py2exe and py2app. I have many  
modules and files with similar issues.

Does anybody know of a third solution?

Massimo

P.S. No need to say this has something to do with www.web2py.com


More information about the Chicago mailing list