I want to get absolute directory path of python file, not current working Directory.
Suppose I have app.py in '/home/user/coding/python/' directory.
Code of app.py is:
# app.py
import os
print(os.getcwd())
- I have been in '/home/user/coding/python/'directory I ranpython app.pyand got
/home/user/coding/python/
- Now I changed dir cdto/home/user/and ranpython '/home/user/coding/python/app.py'and got
/home/user
- But I want the python script to print while running python '/home/user/coding/python/app.py'
/home/user/coding/python/
with python command which means the directory of that python file.
How can I do that?
 
    