Another newbie getopt thread. ^_^

googleboy mynews44 at
Thu Jul 22 17:17:46 CEST 2004

Christopher T King <squirrel at WPI.EDU> wrote a very useful response
which said:

> On 18 Jul 2004, googleboy wrote:
> Using % substitution should work for this:
> help = '%s %s %s\n%s\n%s' % (appname,version,build,author,usage)

> or, if these things are defined in a dictionary:
> help = '%(appname)s %(version)s %(build)s\n%(author)s\n%(usage)s' % helpinfo

Thanks for the tip!  It came a few hours too late to help me.  I
actually ended up defining callbacks to execute a function whenever it
detects a call to help ( -h or --help given as a parameter).

The only issue I have with optparse now came up in final QA testing,
and it isn't a huge problem.  Just *might* be a big enough issue to
keep teh guys I submit it to from using it...   Optparse seems to
ignore any parameters that haven't been defined by anything.   I can
put any sort of spurious characters I like after the command name
interspersed amongst my real and valid switches,  it performs exactly
as though they were not there.   Is there any way for optparse to
automatically bail out in such cases?   I haven't found anything to
help me in the docs,  nor the help list archive.

Thanks again!!!



More information about the Python-list mailing list