program path

Peter Hansen peter at engcorp.com
Sun Jun 8 12:58:46 EDT 2003


Steven Taschuk wrote:
> 
> Quoth Peter Hansen:
>   [...]
> > scriptPath = os.path.abspath(sys.argv[0])
> 
> On machines where sys.argv[0] isn't the absolute path already,
> might it not be the name-as-invoked, and thus ought to be resolved
> by scanning the $PATH (or equivalent) rather than as relative to
> the current directory?

I'm not certain.  Under Win9x, you likely can't invoke the 
script unless you specify the full path (even using the file
assocation probably translates to the same thing).  Under
Linux, experimentation suggests to me that if you invoke
it from the PATH, sys.argv[0] contains the full path already
and the abspath() call is redundant, if harmless.

Can anyone with access to a WinNT/XP machine that can invoke
scripts without explicitly specifying "python.exe" in the 
command line add to this?

-Peter




More information about the Python-list mailing list