I have below directory structure:
E:\<somepath>\PythonProject
-> logs
-> configs
-> source
-> script.py
PythonProject
is my main directory and inside the source
dir I have some python script. From the script.py
I want to access the config file present in configs
. Here I don't want to mention the full path like E:\<somepath>\PythonProject\configs\config.json
a I will be deploying this to a system for which I am not aware of the path. So I decided to go with
config_file_path = os.path.join(os.path.dirname(file))
But this gives me path to the source dir which is E:\<somepath>\PythonProject\source
and I just want E:\<somepath>\PythonProject
so that I can later add configs\config.json
to access the path to config file.
How can I do this. Thanks