Folder structure:
MainFolder
__init__.py
FolderA
Config.json
ConfigHelper.py
testA.py
FolderB
Test.py
ConfigHelper.py file:
import json
class ConfigHelper:
def read_config(self):
fileName = "Config.json"
with open(fileName, "r") as jsonfile:
return json.load(jsonfile)
When calling ConfigHelper.read_config() function from FolderB-->Test.py file , then Getting Error: No such file or directory: 'config.json' But if calling it from TestA.py file, No error is coming. Look like it is taking path relative from the calling place. Please tell me , How I can fix it?