[FRPythoneers] dispatching from a script
ian.g.kelly at gmail.com
Fri Apr 15 18:00:49 MDT 2011
On Fri, Apr 15, 2011 at 4:16 PM, Greg Holling <greg at holling-co.com> wrote:
> The argparse sub-commands functionality is pretty slick. It looks to me you could accomplish the same basic purpose with OptionParser.add_option(), which calls a callback for each command-line option.
So each sub-command would have an option with a callback, where the
callback would invoke a sub-OptionParser to consume the rest of the
command line? I guess you could do that, but since your sub-commands
are actually options they would have to start with '--', which would
be a bit weird. Also the automatically generated help messages would
probably be confusing.
Anyway, optparse is deprecated. New code should just use argparse
unless there's a good reason not to.
More information about the FRPythoneers