I followed Python pattern for sharing configuration throughout application and failed once I tried using it from a different package (folder), can anyone offer a fix?
tree:
|-- my_app | |-- config.py | |-- main.py | |-- my_package | | |-- also.py command line: python -m my_app.main
both main.py and also.py need to use the global configuration from config.py. code in both of them:
import config print("config", config) displays 2 different things!!! main.py says:
('config', <module 'my_app.config' from 'my_app/config.pyc'>) and also.py says:
('config', <module 'config' from '/tmp/project/my_app/config.pyc'>) and it breaks the shared configuration of course :(
I tried following traps but couldn't find anything obvious...
from myapp import configmight solve the problem.py.test my_app/teststhrowsNo module named my_apppython -m pytest my_app/testsinstead