optional arguments with compact reporting in optparse

braver deliverable at gmail.com
Mon Nov 12 14:45:44 EST 2007


Steve -- thanks for your pointer to argparse, awesome progress --
optional arguments.

However, I still wonder how I do reporting.  The idea is that there
should be a list with tuples of the form:

(short, long, value, help)

-- for all options, regardless of whether they were specified on the
command line or not.

Moreover, a way to create such list should be incremental -- in ruby I
define things around each option definition and add a new tuple to the
reporting list right after the block defining the option.

The idea is, -- help should report on all options with their actual or
default values, and everything pertaining to one option -- its
definition, callbacks, and adding it to the reporting list -- must be
in vicinity of each other, so I don't forget to output some stuff
about an option ten options below...  The snippet I've shown pretty
much does it in Ruby.

Ah, yeah, and another thing -- I want to define a module with about 10
options common for a project.  Then I'd import it in scripts, and
there should be three things doable with the preexisting default
options:

-- turn off any of them
-- supply new defaults to any of them
-- add new options in the same way

Wonder how brave pythonistas do that!
Cheers,
Alexy




More information about the Python-list mailing list