optparse help output

Steven Bethard steven.bethard at gmail.com
Wed Oct 24 14:24:36 EDT 2007


Dan wrote:
> On Oct 24, 12:06 pm, Tim Chase <python.l... at tim.thechases.com> wrote:
>>> I've been using optparse for a while, and I have an option with a
>>> number of sub-actions I want to describe in the help section:
>>>     parser.add_option("-a", "--action",
>>>                       help=\
>> [snipped formatted help]> """)
>>
>>> Unfortunately, when I run the script with --help, this is what I get
>>> for the -a option:
>> [snipped munged formatting of help]
>>
>>> Is there any way to get the formatting I want?
>> I had the same issue:
>>
>> http://groups.google.com/group/comp.lang.python/browse_thread/thread/...
>>
>> and was directed by Ben Finney to check out a custom formatter.
>> I got it working to my satisfaction and posted it in that thread:
>>
>> http://groups.google.com/group/comp.lang.python/msg/09f28e26af0699b1
>>
> That was incredibly helpful. I did alter it to format paragraphs, but
> maintain the double newlines. Also, I made a few changes to work with
> the 2.3 version of optparse. Posted below for anyone who might want
> it. (Also to work as a standalone .py file)

You might consider posting it to the optik tracker:

     http://optik.sourceforge.net/

A lot of people have had similar requests.

Steve



More information about the Python-list mailing list