Is there a way to import modules with dependencies within the same directory using an absolute/relative path with \"imp\" ?
Here follows the directory structure:
You need to have __init__.py
in importFrom
directory.
In [5]: ls importFrom/
dependance.py dependant.pyc dependence.pyc __init__.pyc
dependant.py dependence.py __init__.py
In [6]: from importFrom import dependant
In [7]: dependant.dependence
Out[7]:
Instead of importing dependant
in test
, I have used Python interpreter to show the output. In dependant.py
, dependance
is imported.