I have a project that looks like this:
my_project/
__init__.py
run.py
datacheck/
__init__.py
datacheck.py
config.py
business.py
My is PYTHONPATHconfigured to have / my _project in it.
In run.py, I have the following code:
from datacheck.business import BusinessCheck
business = BusinessCheck()
business.check_data()
In business.py, I have the following imports that are not executed:
from datacheck.config import BusinessConfig
from datacheck.datacheck import DataCheck
Relative imports, such as from .config import BusinessConfig, work, however I read in numerous threads that absolute imports are preferable.
To make a simple test, I also created the following:
myproject/
__init__.py -- empty
run_test.py
test/
__init__.py -- empty
test1.py -- containing class Test1(object)
test2.py -- containing class Test2(Test1)
run_test.py imports and runs the class Test2, this did not work.
It stunned me a bit, I don’t understand why my absolute import in datacheck doesn’t work - can anyone explain?