Simple way to get the full path of a running script?
missive at frontiernet.net
Sun Dec 28 20:54:07 CET 2003
> #!/usr/bin/env python
> import sys
> import os
> me = sys.argv
> print "This is how you invoked me: %s" % (me,)
> print "This is the absolute path: %s" % (os.path.abspath(me),)
> mark at dev /var/tmp/buffer
> $ python ../junk.py
> This is how you invoked me: ../junk.py
> This is the absolute path: /var/tmp/junk.py
Is this going to work well cross platform? How about from IDLE?
I was using sys.path which I thought was working well, but
apparently fails when the script is run from IDLE on windows.
More information about the Python-list