Optparse and varible nargs

David Goodger goodger at python.org
Mon Nov 3 20:11:33 EST 2003


John Goebel wrote:
> I have a program that I want to pass a variable number of things
> too. 
> 
> foo_prog -f one two three 

Are "one", "two", and "three" positional arguments or option
arguments?   Can you have a command line like this?

     foo_prog -f one two -g three


If positional arguments, optparse doesn't process them.  If option
arguments, how would optparse know how many to process?  Have you
read "The Tao of Option Parsing"?  If not, please do:
<http://optik.sourceforge.net/tao.html>.

-- David Goodger







More information about the Python-list mailing list