I have the following project structure
SampleProject
com
python
example
source
utils
ConfigManager.py
conf
constants.cfg
How to access constants.cfg from ConfigManager.py.
I have a limitation
- I can not give full path(absolute path) of constants.cfg because if I run in different PC it should work with out any modification
Also if I represent something like below, I can access the file. But I don't want to give back slash every time
filename = ..\\..\\..\\..\\..\\..\\constants.cfg`
Currently I am doing something like this. But this works only when constants.cfg and ConfigManager.py are in same directory
currentDir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
file = open(os.path.join(currentDir,'constants.cfg'))