Let's say that I have a folder, x
, containing the two folders foo
and bar
. Inside foo
I have a Python script and inside bar
, I have my data (let's say a couple of .txt
files). Now, from within my script, I would like to access my data. I could simply use this command and call it a day:
fileList = glob.glob('/absolute/path/to/bar/*.txt')
However, using this method, my script would break if I moved my x
folder.
What's the easiest way to specify the path in a relative manner that allows me to move around the parent folder, x
, freely?