Print current directory path in Python
In order to print current directory path in Python (meaning, directory, where a python script is located), you have to import os module and then run a following script:
dir_path = os.path.dirname(os.path.realpath(__file__))
print(dir_path)
os.path.dirname is defining the current path, where your python script is stored and second line prints it into command line (terminal).
Output:
dima@linux-zsrx:~/python> python files.py
/home/dima/python
dima@linux-zsrx:~/python>