On 6 avr, 12:48, Massimo Di Pierro <massimo.dipie...@gmail.com> wrote: > I would like to see an example of custom importer, it would help me > understand the problem that needs to be solved. >
I think it would be really simple. Just rebind the __import__ to create an around advice that will try a relative import. Just count the number of parent directories from the module doing the import to "modules". Use the old __import__ to do the relative import and if it generates an import error, call the old __import__ with the parameters your new __import__ received. See help(__import__) and http://books.google.ca/books?id=JnR9hQA3SncC&pg=PA147&lpg=PA147&dq=python+custom+importer&source=bl&ots=Jb1TFp194s&sig=PFnaZB4aIubwyjXbmpsoChIKqAM&hl=fr&ei=FpucTZmWJ-y10QHn1LzjAg&sa=X&oi=book_result&ct=result&resnum=6&ved=0CEwQ6AEwBQ#v=onepage&q=python%20custom%20importer&f=false Sounds easy?