Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #66893
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'insert': 0.05; 'parser': 0.07; 'here?': 0.09; 'mess': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'run,': 0.09; 'subject:question': 0.10; "'''))": 0.16; 'defined.': 0.16; 'illustrating': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:argparse': 0.16; 'textwrap': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'module': 0.19; 'trying': 0.19; 'example': 0.22; 'import': 0.22; 'saying': 0.22; 'header:User-Agent:1': 0.23; 'either.': 0.24; 'second': 0.26; 'header:X-Complaints-To:1': 0.27; "doesn't": 0.30; 'gives': 0.31; 'code': 0.31; 'larry': 0.31; 'skip:- 30': 0.32; 'run': 0.32; 'running': 0.33; 'beginning': 0.33; 'but': 0.35; 'method': 0.36; 'should': 0.36; 'error.': 0.37; 'to:addr:python-list': 0.38; 'delete': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'deleting': 0.60; 'show': 0.63; 'skip:f 50': 0.65; 'line,': 0.68 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Peter Otten <__peter__@web.de> |
| Subject | Re: argparse question |
| Date | Sat, 22 Feb 2014 12:58:15 +0100 |
| Organization | None |
| References | <y-ednQHk88Q3H5XOnZ2dnUVZ_judnZ2d@giganews.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Gmane-NNTP-Posting-Host | p57bdbfea.dip0.t-ipconnect.de |
| User-Agent | KNode/4.7.3 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.7260.1393070405.18130.python-list@python.org> (permalink) |
| Lines | 41 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1393070405 news.xs4all.nl 2937 [2001:888:2000:d::a6]:49964 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:66893 |
Show key headers only | View raw
Larry Hudson wrote:
> I have been reading the argparse section of the 3.3 docs, and running all
> the example code.
>
> But in section 16.4.2.6. for the formatter_class, the second example in
> that section illustrating RawDescriptionHelpFormatter, the example code
> is:
>
> parser = argparse.ArgumentParser(
> prog='PROG',
> formatter_class=argparse.RawDescriptionHelpFormatter,
> description=textwrap.dedent('''\
> Please do not mess up this text!
> --------------------------------
> I have indented it
> exactly the way
> I want it
> '''))
> parser.print_help()
>
> But trying to run this gives a NameError on the "description=" line,
> saying textwrap is not
> defined. If I delete the "textwrap.dedent" (with or without also deleting
> the extra parentheses) it will then run, but without the un-indenting it
> is trying to illustrate.
>
> What is the proper way to enable the dedent() method here?
textwrap is a module like argparse, and the example doesn't show
import argparse
either. Insert
import textwrap
at the beginning of your module and the code should run without error.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
argparse question Larry Hudson <orgnut@yahoo.com> - 2014-02-22 02:57 -0800
Re: argparse question Peter Otten <__peter__@web.de> - 2014-02-22 12:58 +0100
Re: argparse question Larry Hudson <orgnut@yahoo.com> - 2014-02-22 21:58 -0800
csiph-web