Optparse and varible nargs

David Goodger goodger at python.org
Tue Nov 4 02:11:33 CET 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:

-- David Goodger

More information about the Python-list mailing list