[Python-3000] Move argv[0]? (Re: Unicode and OS strings)

Thomas Wouters thomas at python.org
Wed Sep 19 03:40:40 CEST 2007


On 9/16/07, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:
>
> Thomas Wouters wrote:
> > If you want to put more meaning in the argv list, use an option
> > parser.
>
> I want to put *less* meaning in it, not more. :-)


Then why are you discriminating against argv[0]? It's just another member of
the argv list the OS gives us.

And using an argument parser is often overkill for
> simple programs.


So is trying to "fix" this non-issue.

> The _actual_ meaning of each element depends entirely on the
> > program that's started. For Python-the-language, there isn't any
> > difference between them.
>
> So in your Python programs, you're quite happy
> to write
>
>    for arg in sys.argv:
>      process(arg)
>
> and not care about what this does with argv[0]?


No. I'm quite happy to realize the argv list is what the shell executed. I'm
also quite happy to use a proper option parser even for my simple programs.
It adds useful defaults even if I didn't think I'd ever use them.

I hardly see how one can claim that there's
> "no difference" between argv[0] and the rest
> for practical purposes.


The only meaning is by accident of position. For most programs, the very
same thing goes for the rest of the arguments: 'mv foo bar' assigns a
different meaning to 'foo' than it does to 'bar'. Notice how
sys.argvmatches what the user typed, including
sys.argv[0].

-- 
Thomas Wouters <thomas at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-3000/attachments/20070918/481aff7f/attachment.htm 


More information about the Python-3000 mailing list