Python - print the absolute path of the current file

This is just a small note when I tried to get the path of the current (python) file:

#! /usr/bin python
import os

print os.path.dirname(os.path.abspath(__file__))


Note: The above script wont work in the Python REPL shell.



Comments