optparse: best way

hiral hiralsmaillist at gmail.com
Tue Jun 8 04:38:23 EDT 2010


Hi,

I am using optparser to do following...

Command syntax:
myscript -o[exension] other_arguments
    where; extension can be 'exe', 'txt', 'pdf', 'ppt' etc.


Now to parse this, I am doing following...

parser.add_option("-oexe', dest=exe_file...)
parser.add_option("-otxt', dest=txt_file...)
parser.add_option("-opdf', dest=pdf_file...)
parser.add_option("-oppt', dest=ppt_file...)

The above way is the most simple way to parser options.
Can you please suggest any other best way / optimized way to parse
these kind of options.

Thank you in advance.



More information about the Python-list mailing list