Lets say i have a python script at homedir/codes/py/run.py
I also have a bash script at homedir/codes/run.sh
This bash script runs run.py by python py/run.py.
The thing is that i need to be able to find out, in run.py, the path to the calling script run.sh. If run.sh is run from its own directory, i can just use os.getcwd(). But run.sh can in principle be run from anywhere, and then os.getcwd() will return the path to where run.sh is run FROM, and not the actual location of run.sh.
ex:
- At 
homedir/codes:./run.sh->os.getcwd()returnshomedir/codes - At 
homedir:./codes/run.sh->os.getcwd()returnshomedir 
But i want homedir/codes no matter how run.sh is called. Is this possible?
run.sh?python py/run.py, it must be run fromhomedir/codesotherwisepy/run.pywouldn't be found. So your question is not complete.