argv[0] manipulation
P_spam_ at draigBrady.com
P_spam_ at draigBrady.com
Wed Dec 11 10:42:59 EST 2002
Mike Meyer wrote:
> 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".
And if the user types
"python relative/path/to/program arguments that are wrong".
The python program then spits out an error message that looks like:
usage: relative/path/to/program arguments that are right
I.E. you really should be using os.path.split(argv[0]) as I said.
Anyway this whole point is invalid as I don't think it's useful.
I had assumed that the shell passes what you type for executables
in the $PATH directly in argv[0]. This is silly of course and
it just passes appropriate_path_entry+'/'+what_you_type so you can't
distinguish from argv[0] whether a program was found in the $PATH
or explicitly specified by the user.
Anyway I've attached a patch (against 2.2.2) for the record.
thanks,
Pádraig.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: equiv_argv0.diff
URL: <http://mail.python.org/pipermail/python-list/attachments/20021211/a2349102/attachment.ksh>
More information about the Python-list
mailing list