optionparse: how to add a line break to the help text

Tim Chase python.list at tim.thechases.com
Sat Sep 10 22:08:45 EDT 2011

On 09/10/11 20:54, Gelonida N wrote:
>> Unfortunately the help text is formatted using textwrap, which presumes
>> that the entire text is a single paragraph.  To get paragraphs in the
>> help text, you'll need to write an IndentedHelpFormatter subclass that
>> splits the text on "\n\n", textwraps the split string individually, then
>> re-joins them.  _format_text() and format_option() look like the methods
>> that would need replacing.
> Thanks a lot. Good to know, that there are options, though a little more
> complicated than expected.

Just in case you want it:


it's come up several times and several years ago I hacked 
together exactly the solution Rhodri mentions.


More information about the Python-list mailing list