python optparse multiple arguments

56 views
Skip to first unread message

Ritesh Raj Sarraf

unread,
Jun 30, 2006, 4:46:26 AM6/30/06
to Linux-Nepal
Hi,

I'm having some minor problems with optparse. I'm just worried that
someone shouldn't say that multiple argument feature isn't implemented
in optpartse.


How to tackle multiple arguments to an option ?
As far as I dug, I've found that >1 arguments are being ignored.


parser.add_option("", "--my-option", dest="my_option", action="store",
type="string")


Now if someone uses it as:
./foo --my-option a b c


I want somehow to store all the three arguments but my_option stores
only "a" while ignoring b and c.


Any help?


Ritesh

Ritesh Raj Sarraf

unread,
Jun 30, 2006, 5:02:41 AM6/30/06
to Linux-Nepal

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

Reply all
Reply to author
Forward
0 new messages