ANNOUNCE: Optik 1.0 (new command-line parsing library)

Oleg Broytmann phd at
Mon Nov 12 15:53:57 CET 2001


On Mon, Nov 12, 2001 at 09:33:08AM -0500, Greg Ward wrote:
>   from optik import OptionParser
>   [...]
>   parser = OptionParser()
>   parser.add_option("-f", "--file",
>                     action="store", type="string", dest="filename",
>                     help="write report to FILE", metavar="FILE")
>   (options, args) = parser.parse_args()
> With these few lines of code, users of your script can now do the
> "usual thing" on the command-line:
>   <yourscript> --file outfile
> (All of these result in
>   options.filename == "outfile"

   Can it handle multiple arguments for an option?

<yourscript> --file outfile1 outfile2

   Or mix options and arguments?

<yourscript> --file outfile infile -q

   Handle multiple args with the same name?

<yourscript> --file outfile1 -f outfile2

     Oleg Broytmann              phd at
           Programmers don't die, they just GOSUB without RETURN.

More information about the Python-list mailing list