I have Directory structure like this
projectfolder/fold1/fold2/fold3/script.py
now I\'m giving script.py a path as commandline argument of a fi
A practical example:
sys.argv[0]
gives you the name of the current script
os.path.dirname()
gives you the relative directory name
thus, the next line, gives you the absolute working directory of the current executing file.
cwd = os.path.abspath(os.path.dirname(sys.argv[0]))
Personally, I always use this instead of os.getcwd()
since it gives me the script absolute path, independent of the directory from where the script was called.