I'm trying to return the current folder path of a python script, here is what I have
#test.py
import os
THIS_FOLDER = os.path.dirname(os.path.abspath('__file__'))
print(THIS_FOLDER)
When I run this script, it returns the folder that I am in when running it in the command prompt, not the folder of the python script.. How can I return the folder of the current python file?
user@vm:~$ python -u dir/test.py
/home/user
user@vm:~$ cd dir
user@vm:~/dir$ python -u test.py
/home/user/dir