argv[0] manipulation

Grant Edwards grante at visi.com
Thu Dec 12 10:42:36 EST 2002


In article <slrnavhbcp.8dm.rmunn at rmunnlfs.dyndns.org>, Robin Munn wrote:

> *Boggle*. Do you mean that tcsh and ksh, if "myscript.py" is
> found in $PATH, simply pass "myscript.py" as argv[0] instead of
> passing "/home/myusername/bin/myscript.py"?

Yes.

> Then how am I supposed to, say, check for a config file in my
> script's directory?

You're not.  That's considered bad behavior.

> Or find the data file locations based on my script's location?

You're not supposed to.  That's also considered bad behavior.

>>> Python does what it should with argv, copies it directly into sys.argv.
>> 
>> Definitely agreed.

Remember: the contents of argv[0] are dependent _entirely_ on
the whim of the calling program.  You can _not_ assume it
contains anything useful.

-- 
Grant Edwards                   grante             Yow!  PEGGY FLEMING is
                                  at               stealing BASKET BALLS to
                               visi.com            feed the babies in VERMONT.



More information about the Python-list mailing list