program path

Steven Taschuk staschuk at
Sun Jun 8 20:07:11 CEST 2003

Quoth Peter Hansen:
> 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.

On my Linux whether the path is absolute depends on whether the
relevant element of $PATH is, so the abspath() call might not be
redundant.  Example:

    $ cat tmp/foo
    $ PATH=tmp foo

But certainly the value seen is not $PATH-relative, which was my
concern.  (This depends on the shebang mechanism, I think; a C
program gets its name-as-invoked in argv[0].  But obviously an
interpreter named in a shebang line would in general not want a
$PATH-relative name.)

I've no clue of Windows or Mac behaviour on this point.

Steven Taschuk                                     staschuk at
Receive them ignorant; dispatch them confused.  (Weschler's Teaching Motto)

More information about the Python-list mailing list