Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #13099

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

Date 2011-09-10 21:08 -0500
From Tim Chase <python.list@tim.thechases.com>
Subject Re: optionparse: how to add a line break to the help text
References <j4gi5r$gjc$1@dough.gmane.org> <mailman.952.1315693006.27778.python-list@python.org> <op.v1mdm0oba8ncjz@gnudebst> <j4h4dh$60n$1@dough.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.962.1315706938.27778.python-list@python.org> (permalink)

Show all headers | View raw


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:

http://bytes.com/topic/python/answers/734066-how-output-newline-carriage-return-optparse

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

-tkc

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: optionparse: how to add a line break to the help text Rafael Durán Castañeda <rafadurancastaneda@gmail.com> - 2011-09-11 00:16 +0200
  Re: optionparse: how to add a line break to the help text "Rhodri James" <rhodri@wildebst.demon.co.uk> - 2011-09-11 02:12 +0100
    Re: optionparse: how to add a line break to the help text Gelonida N <gelonida@gmail.com> - 2011-09-11 03:54 +0200
    Re: optionparse: how to add a line break to the help text Tim Chase <python.list@tim.thechases.com> - 2011-09-10 21:08 -0500
    Re: optionparse: how to add a line break to the help text Gelonida N <gelonida@gmail.com> - 2011-09-11 05:07 +0200
      Re: optionparse: how to add a line break to the help text Ben Finney <ben+python@benfinney.id.au> - 2011-09-11 15:20 +1000
        Re: optionparse: how to add a line break to the help text Gelonida N <gelonida@gmail.com> - 2011-09-11 16:30 +0200
    Re: optionparse: how to add a line break to the help text Tim Chase <python.list@tim.thechases.com> - 2011-09-11 06:05 -0500
    Re: optionparse: how to add a line break to the help text Robert Kern <robert.kern@gmail.com> - 2011-09-11 15:22 -0500

csiph-web