optparse: add trailing text in help message?

Steven Bethard steven.bethard at gmail.com
Sat Oct 14 12:39:25 EDT 2006


Count László de Almásy wrote:
> Is there a standard way with optparse to include a blurb of text after
> the usage section, description, and the list of options?  This is
> often useful to include examples or closing comments when the help
> message is printed out.  Many of the GNU commands do this.
> 
> It would look something like this:
> 
> % program --help
> 
> usage: program [options]
> 
> This is my description text.
> 
> options:
>  -f BAR, --foo=BAR
>                 A sample option
>  --version   show program's version number and exit
>  --help       show this help message and exit
> 
> ==> Now how about closing text after the options list?

What would you like this API to look like?  I could add this pretty 
easily to argparse_ this week.  Maybe something like::

     parser = argparse.ArgumentParser(
         description='This is my ...',
         tail='Now how about closing ...'
     )

Or is there another API that would be better?

.. _argparse: http://argparse.python-hosting.com/

STeVe



More information about the Python-list mailing list