FIXED: Re: optparse multiple arguments

Simon Percivall percivall at gmail.com
Fri Jun 30 12:01:57 CEST 2006


Ritesh Raj Sarraf wrote:
> Ritesh Raj Sarraf wrote:
> > I just noticed that the args variable is holding values b and c.
> > the args variables comes from:
> > (options, args) = parser.parse_args()
> >
> > I guess I only need to figure out now is why args isn't storing
> > argument "a" also...
> >
> > Ritesh
>
> I fixed it, I guess.
>
> parser.add_option("", "--my-option", dest="my_option",
> action="store_true")
>
> sets my_option to True and the arguments are all stored in the list
> "args". :-)
>
> Ritesh

It might do you good to read the documentation instead of blindly
experimenting.

Anyway,

parser.add_option("", "--my-option", nargs=3)

http://docs.python.org/lib/optparse-standard-option-actions.html




More information about the Python-list mailing list