Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '(of': 0.05; 'snippet': 0.07; ':-(': 0.09; 'optparse': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subclass': 0.09; 'tim,': 0.09; ';-)': 0.12; 'am,': 0.12; 'library': 0.15; 'hacked': 0.16; 'splits': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'subject:help': 0.22; 'header:In-Reply-To:1': 0.22; 'structure': 0.23; 'string': 0.26; 'posted': 0.26; "i'm": 0.27; 'problem': 0.28; 'thanks': 0.30; 'ago': 0.31; 'probably': 0.33; 'to:addr:python-list': 0.33; 'header:User-Agent:1': 0.34; 'header:X-Complaints-To:1': 0.35; 'subject:text': 0.35; 'url:python': 0.36; 'using': 0.37; 'several': 0.37; 'received:org': 0.38; 'subject:: ': 0.39; 'help': 0.39; 'header:Mime-Version:1': 0.39; 'to:addr:python.org': 0.39; 'case': 0.39; "it's": 0.40; 'more': 0.60; 'become': 0.71; 'subject:line': 0.73; '04:08': 0.84; 'paragraphs': 0.84; 'url:answers': 0.84; 'url:topic': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Gelonida N Subject: Re: optionparse: how to add a line break to the help text Date: Sun, 11 Sep 2011 05:07:28 +0200 References: <4E6C182D.60905@tim.thechases.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: unicorn.dungeon.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Lightning/1.0b2 "" In-Reply-To: <4E6C182D.60905@tim.thechases.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315710463 news.xs4all.nl 2464 [2001:888:2000:d::a6]:58875 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:13102 Hi Tim, Thanks a lot!!! On 09/11/2011 04:08 AM, Tim Chase wrote: > 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. > > Just in case you want it: > > http://bytes.com/topic/python/answers/734066-how-output-newline-carriage-return-optparse > It works (of course ;-) ) like a charm. Good to know, that I'm not the only one who want's to structure the help text a little nicer. > > it's come up several times and several years ago I hacked together > exactly the solution Rhodri mentions. Considering, that you posted the snippet in 2007 and this is very probably a reocurring problem for any slighty more complicated help text it is really a pity, that it did not become of part of the standard optparse library :-( Thanks again.