argv[0] manipulation

Mike Meyer mwm at mired.org
Wed Dec 11 10:06:28 EST 2002


P_spam_ at draigBrady.com writes:

> Mike Meyer wrote:
> > Well, it could make other people's handling of arguments more painfull
> > and/or ugly, depending.
> Can you think of any examples? A prepended './' should have no
> logical effect at least. For e.g. to get the program name you
> needed to do os.path.split() anyway, so this will have no effect?

Sure. User types "python program arguments that are wrong". The python program
then spits out an error message that looks like:

        usage: program arguments that are right

With your change in place, the usage message will list "./program",
not "program".

> > Is there some reason you don't want to keep your curernt arrangement
> > and just type "python ./myscript" to get debugging, and "python
> > myscript" to get it without debugging?
> Because I'll forget 

Personally, I think correct usage messages are a lot more important.

> but more importantly I want this transparent to 3rd parties.

To me, it's a *lot* more transparent if using "./myscript" got
debuging info and using "myscript" didn't, no matter whether the user
invoked it by giving it as an argument to python or letting the
system's exec do that for them.

        <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list