optparse: best way

hiral hiralsmaillist at gmail.com
Wed Jun 9 05:54:12 EDT 2010


On Jun 8, 4:30 pm, Hrvoje Niksic <hnik... at xemacs.org> wrote:
> Thomas Jollans <tho... at jollans.com> writes:
> > UNIX and GNU recommendations. I've never actually heard of optparser,
> > but I'd expect it to have the usual limitations:
>
> Hiralprobably meant to write "optparse", which supports GNU-style
> options in a fairly standard and straightforward way.  Which includes
> that defining a "-o"/"--output-format" option that takes an argument
> allows you to write one of "-o exe", "-oexe", "--output-format=exe", or
> "--output-format exe".
>
> My recommendation is to use -o, and -oexe will work just fine.

Thank you all :) for your kind suggestins.
All your suggestions are fine and valid, which suggest to have option
'-o' and take its value 'exe ppt pdf txt' etc.

Yes, I am planning to use GNU style options...
One advantage with this that user can pass a.txt but can specify it as
'-oexe' and it would get executed as 'process_exe()'.

So to say we don't have support for '-o<extensions> value' in python;
but there are ways to acheive this.
It seems as of now I should specify them as seperate options like...
> parser.add_option("-o', dest=exe_file...)
> 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...)

Thank you in advance.
-Hiral



More information about the Python-list mailing list