Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34310
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ian.g.kelly@gmail.com> |
| 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; 'else:': 0.03; 'args': 0.04; 'exception.': 0.07; 'subject:How': 0.09; 'subject:command': 0.09; 'dec': 0.15; 'argparse': 0.16; 'statement.': 0.16; 'subject: \n ': 0.16; 'subject:argparse': 0.16; 'subject:options': 0.16; 'subject:usage': 0.16; 'subject:when': 0.16; 'sys.exit(1)': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'examples': 0.18; 'command': 0.24; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'separate': 0.27; 'message-id:@mail.gmail.com': 0.27; 'options': 0.27; 'received:209.85.215.46': 0.30; 'print': 0.32; 'to:addr:python- list': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'wanted': 0.36; "didn't": 0.36; 'skip:p 20': 0.36; 'received:209': 0.37; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'to:name:python': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=Pmr/AGeExuXKf6qzgBQo/IcktqTbPbY+yA5FarSPCtw=; b=G03Y+0WqB3X1GuF9zxJraXkq7wy9c/GYz5E4czXG5S1VXKsMnqcpMQJLFCrN1GdJPN XTPQuIY4EYuJk79z9AwU6ELQR70tPmmA3GOkVcoKPAGgulBENl2vawTSjlkpSKgoFlLL 1hMg01ZkQ69mzosWAyujXBSkkjyfG1bSQi66CSyzabEA7eJSWndP4C53mrs5dXSqoCwz SUFtbUTzfkgFRMZmZU2pMzZ1XT5L096pFLVvCu34Fx/ZjSc+4PHHL2mPmBrMGYPqy+nP +Z5spKwfeGwRi3xcN4BKg9CBb2dU/5DrdyurWvYWN20i7U2xD9pkSMvV46ATzK00cKDu eHhw== |
| MIME-Version | 1.0 |
| In-Reply-To | <20121205084830.74e842119d151781db385406@lavabit.com> |
| References | <20121205084830.74e842119d151781db385406@lavabit.com> |
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | Wed, 5 Dec 2012 11:31:57 -0700 |
| Subject | Re: How does one make argparse print usage when no options are provided on the command line? |
| To | Python <python-list@python.org> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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 | <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.517.1354732351.29569.python-list@python.org> (permalink) |
| Lines | 12 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1354732351 news.xs4all.nl 6955 [2001:888:2000:d::a6]:46505 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:34310 |
Show key headers only | View raw
On Wed, Dec 5, 2012 at 9:48 AM, rh <richard_hubbe11@lavabit.com> wrote:
> I have argparse working with one exception. I wanted the program to print out
> usage when no command line options are given. But I only came across
> other examples where people didn't use argparse but instead printed out
> a separate usage statement. So they used argparse for everything but the
> case where no command line args are given.
if len(sys.argv) <= 1:
parser.print_usage()
sys.exit(1)
else:
args = parser.parse_args()
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: How does one make argparse print usage when no options are provided on the command line? Ian Kelly <ian.g.kelly@gmail.com> - 2012-12-05 11:31 -0700
csiph-web