[getopt-sig] A simple remark for the next Python command line option standard parser

Greg Ward gward@python.net
Thu, 14 Feb 2002 13:22:07 -0500


On 14 February 2002, Laurent Pointal said:
> A problem I encounter with standard getopt module is its absolute necessity 
> to know all possible options (it raises an exception for unknown options).
> 
> I'm in the context of a tool module, with its **own** options. Application 
> programmer use this module but dont have to care with its specific options 
> (that may change as module evoluate).

That was one of the motivating factors behind Optik.  The way it works
is this:

  * you define your own OptionParser subclass with its own
    STANDARD_OPTIONS class attribute; this is a list of Option
    instances

  * applications instantiate your OptionParser subclass, and then
    add_option() any of their own options

With an iterative model, things would be different: the "base" module
would probably provide a function that you call on each iteration of the
option-parsing loop, which just looks for the base module's own options.
Russ, does this make sense?

        Greg
-- 
Greg Ward - Python bigot                                gward@python.net
http://starship.python.net/~gward/
The world is coming to an end.  Please log off.