Re: Changing sys.argv[-1]

Guido.van.Rossum@cwi.nl
Wed, 16 Mar 1994 14:13:17 +0100

> Hope you're not to sick of me yet.

Hmm... Maybe you could shorten your signature to two lines :-)

> Right, what I would like to do is change the python process's argv
> so that a ps shows the <script name> not python <scriptname>. Now
> sys.argv[0] contains the script name, and it is possible to do this,
> perl does using $0, but I think it is OS dependent.

For executable python scripts with #! /usr/local/bin/python as their
first line, this happens automatically on my system (SGI IRIX 4).

If you run the Python interpreter with the script as first argument,
the script name appears in sys.argv[0] but "python" appears in the ps
listing. The same is true for Perl though (except there "perl" appers
in the ps listing :-).

--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
URL: <http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>