I have the following:
% more a.py
import os
os.system('pwd')
% python a.py
/Users/yl/test/f
% cd ..
% python ./f/a.py
/Users/yl/test
Basically I want the last output to be "/Users/yl/test/f", which is the path where the script is located (not where python was invoked). Have played around but didn't find a good solution. Thanks for any suggestions!