I want to create a file outside the current working directory in python. Here's my directory structure.
|--myproject
| |-- gui
| | |-- modules
| | | |-- energy
| | | | |-- configuration
| | | | | |-- working_file.py
| |-- service
| | |-- constants
| | | |-- global_variables.json
I'm current working in /myproject/gui/energy/configuration/working_file.py
and I want to create a file under /myproject/service/constants
named global_variables.json
I tried
with open("../../../../../service/constants/global_variables.json", 'w') as file_handler:
content = json.load(file_handler)