Name of the Script

Pearu Peterson pearu at cens.ioc.ee
Mon Mar 5 10:17:38 EST 2001


On Mon, 5 Mar 2001, Paul Moore wrote:

> 
> This doesn't always include full pathname information. On Windows,
> 
> --- a.py ---
> import sys
> print sys.argv[0]
> ---
> 
> python a.py
> 
> just prints "a.py". Is there a way of getting the *full* script name.
> For example, so that the script can locate a data file which is held
> in the same directory as the script itself.

--- a.py ---
import os,sys
print os.path.abspath(sys.argv[0])
---
might be what you want.

Pearu




More information about the Python-list mailing list