I am trying to access a text file in the parent directory,
Eg : python script is in codeSrc & the text file is in mainFolder.
G###script path:\mainFolder\codeSrc\fun.py
G:\mainFolder\codeSrc\fun.py
G###desired file path:\mainFolder\foo.txt
G:\mainFolder\foo.txt
I am currently using this syntax with python 2.7x,
import os
filename = os.path.dirname(os.getcwd())+"\\foo.txt"
Although this works fine I want to know if, is there a better (prettier :P) way to do this.?