Example Project:
|- main.py
|- Module
|- __init__.py
|- worker.py
|- worker_config.json
main.py
from Module import worker
#do stuff ...
worker.py
import json
mySettings = json.load(open("worker_config.json", "r"))
#more stuff ...
Running worker.py on it's own works. Importing worker.py from main.py works basically also. But when worker.py is imported by main.py, the worker_config.json file can't be accessed, because the path has now changed to the main folder.
Is there a way to fix the path for the worker_config file when the module is imported and still ensure that the file can be accessed when worker.py is directly executed?