Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed6.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'args': 0.05; 'parser': 0.05; '"""': 0.07; 'suggestions.': 0.07; 'optparse': 0.09; 'width.': 0.09; 'stripped': 0.16; 'wrote:': 0.16; 'advance': 0.18; '>>>': 0.18; 'insert': 0.19; 'received:74.125.82.174': 0.19; 'received:mail- wy0-f174.google.com': 0.19; 'subject:help': 0.22; 'header:In- Reply-To:1': 0.22; 'structure': 0.23; 'thus': 0.23; 'breaks': 0.23; 'received:192.168.1.100': 0.23; 'wondered': 0.23; "i'm": 0.27; 'import': 0.28; 'thanks': 0.30; "skip:' 10": 0.30; 'break': 0.32; 'there': 0.33; 'to:addr:python-list': 0.33; 'header:User- Agent:1': 0.34; 'force': 0.34; 'message-id:@gmail.com': 0.34; 'from:charset:iso-8859-1': 0.35; 'subject:text': 0.35; 'explain': 0.36; 'question': 0.36; 'skip:" 10': 0.36; 'options': 0.37; 'received:74.125.82': 0.38; 'received:google.com': 0.38; 'subject:: ': 0.39; 'received:192': 0.39; 'difficult': 0.39; 'option': 0.39; 'help': 0.39; 'to:addr:python.org': 0.39; 'received:74.125': 0.39; "i'd": 0.40; "it's": 0.40; 'according': 0.62; 'subject:line': 0.73; 'off"': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=FWQni3cBhXcfaqxCk9oxH1aCRTdyUF734lGXUt1fr0Q=; b=puKCQl4w052fnJRcwd2dCe1KesLNN1BtYa0C3jH8ERFalwyLrQ2UqauFuqKAKvjFfq nf/oY64j2rilFx9/430m7XHt9Qb9zddgqQsv/MBROPhv9AoUxAOVoPmu9iJ9CLB/iVsn LjMy05B7sRD0bEs/GKYXppO6y+LuLmT0E6Yb0= Date: Sun, 11 Sep 2011 00:16:42 +0200 From: =?ISO-8859-1?Q?Rafael_Dur=E1n_Casta=F1eda?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13 MIME-Version: 1.0 To: python-list@python.org Subject: Re: optionparse: how to add a line break to the help text References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1315693006 news.xs4all.nl 2511 [2001:888:2000:d::a6]:35758 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:13086 On 10/09/11 22:43, Gelonida N wrote: > I'm having a small question about optionparse. > > Normaly optionparser will format the help text according to the > console's width. > > I just wondered if there is any way to insert a line breakk into an > options help text. > > Example: > > from optparse import OptionParser > > parser = OptionParser() > parser.add_option("-f", action="store", > help="This option is really really complicated" > " and I'd like to write" > " a few paragrpahs to explain how it works." > "\nHowever the line breaks are stripped off" > " and it's thus difficult to structure the help text") > > args = ['-h'] > parser.parse_args(args) > > Is there any trick to force a new paragraph/ line break before the word > 'However'? > > > Thanks in advance for suggestions. > > You can use """ for multiple line texts: >>> text = \ ... """fsdfsfsdfsdf ... sfsdfsfsdf ... sdfsdf s ... ... """ >>> text 'fsdfsfsdfsdf\n sfsdfsfsdf\nsdfsdf s\n\n'