Reputation: 12697
I have a Pydev/Eclipse project with a src/ directory and a data/ directory. Is there an easy way to access the full path of data/ (and the files there) from within a Python script (in src) without specifying the full data path explicitely?
Upvotes: 0
Views: 173
Reputation: 3090
You could do
import os
print os.getcwd()
and then just remove the /src/ part and add /data/. It would technically be the full path but It would be working using the assumption that src and data are int the same top folder.
[Edit]
Something like this (if you are on *nix)
import os
path = os.getcwd()
split_path = path.split('/')
new_path = ''.join([s + '/' for s in split_path[:-1]])
new_path += 'data/'
Guess it will be similar on Windows
Upvotes: 1