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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.013
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'subclass': 0.09; '-tkc': 0.16; 'expected.': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'hacked': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'splits': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.16; 'cc:no real name:2**0': 0.20; 'subject:help': 0.22; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'string': 0.26; 'cc:addr:python.org': 0.30; 'lot.': 0.30; 'thanks': 0.30; 'ago': 0.31; 'there': 0.33; 'header:User-Agent:1': 0.34; 'subject:text': 0.35; 'url:python': 0.36; 'using': 0.37; 'several': 0.37; 'subject:: ': 0.39; 'help': 0.39; 'case': 0.39; "it's": 0.40; 'more': 0.60; 'subject:line': 0.73; 'paragraphs': 0.84; 'url:answers': 0.84; 'url:topic': 0.91
Date Sat, 10 Sep 2011 21:08:45 -0500
From Tim Chase <python.list@tim.thechases.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.20) Gecko/20110826 Icedove/3.1.12
MIME-Version 1.0
To Gelonida N <gelonida@gmail.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>
In-Reply-To <j4h4dh$60n$1@dough.gmane.org>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Source
X-Source-Args
X-Source-Dir
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.962.1315706938.27778.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1315706938 news.xs4all.nl 2477 [2001:888:2000:d::a6]:56809
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:13099

Show key headers only | 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