How can I find the full path to the currently running Python script? That is to say, what do I have to do to achieve this:
$ pwd /tmp $ python baz.py running
The script name will (always?) be the first index of sys.argv:
import sys print sys.argv[0]
An even easier way to find the path of your running script:
os.path.dirname(sys.argv[0])