Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49315
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!nuzba.szn.dk!pnx.dk!news.stupi.se!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 | <robotsondrugs@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; 'argument': 0.05; 'cpython': 0.05; 'ugly': 0.07; 'arguments': 0.09; 'caller': 0.09; 'exception.': 0.09; 'imported': 0.09; 'propagate': 0.09; 'subject:Why': 0.09; 'subject:module': 0.09; 'useful,': 0.14; 'windows': 0.15; 'attributes).': 0.16; 'letting': 0.16; 'overriding': 0.16; 'raised,': 0.16; 'subject:argparse': 0.16; 'supplied': 0.16; 'exception': 0.16; 'module': 0.19; 'normally': 0.19; 'user.': 0.19; 'meant': 0.20; 'input': 0.22; 'header:User- Agent:1': 0.23; "aren't": 0.24; 'case.': 0.24; 'parse': 0.24; "i've": 0.25; 'wonder': 0.29; "doesn't": 0.30; '(which': 0.31; 'terminate': 0.31; 'figure': 0.32; 'trouble': 0.34; 'subject:the': 0.34; "i'd": 0.34; 'display': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'useful': 0.36; 'subject:?': 0.36; 'message-id:@gmail.com': 0.38; 'handle': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'skip:u 10': 0.60; 'most': 0.60; 'information': 0.63; 'great': 0.65; 'caused': 0.69; 'presented': 0.69; '9.1': 0.84; 'freebsd': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=wfchyv3fnGLxM0xI5Sk9pQsurmJbQesvAAc5URA2p+A=; b=p2+cNKnCpwlGLxxp7jdbS+jNMEJQBx6JdbeLZy+hmW9f2EzpELepMs6n1eClYlIDrh fcD4IEIPMjl2RruqCPOOrKaTIKSc49Yiwxd4Q/TJlUt/xyvNnQkbFJD479N78MPVAi64 kwXM5vm1/E+zJmm9hAqnbGQ7kjj3XL44BZr0N49q8FItd1Ivd1+dVHjXEQbN3CrRpsdp jTz5WwlO7NDHpUWQmPveJ+H9++Ii2mmnxWirZTIJhwlqfO+QaZffe+t2UTH2+gBfNl8L l/X4Nq7s84eW0I5jP0yS3F4CPrp1pENw+l1nxzpMeagJ+6Q846GbXsHP/lPMGmJRzLT4 XDOg== |
| X-Received | by 10.50.21.70 with SMTP id t6mr15568096ige.36.1372337696012; Thu, 27 Jun 2013 05:54:56 -0700 (PDT) |
| Date | Thu, 27 Jun 2013 07:54:12 -0500 |
| From | Andrew Berg <robotsondrugs@gmail.com> |
| User-Agent | Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 |
| MIME-Version | 1.0 |
| To | "comp.lang.python" <python-list@python.org> |
| Subject | Why is the argparse module so inflexible? |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | 7bit |
| 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.3924.1372337705.3114.python-list@python.org> (permalink) |
| Lines | 10 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1372337705 news.xs4all.nl 15962 [2001:888:2000:d::a6]:45319 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:49315 |
Show key headers only | View raw
I've begun writing a program with an interactive prompt, and it needs to parse input from the user. I thought the argparse module would be great for this, but unfortunately it insists on calling sys.exit() at any sign of trouble instead of letting its ArgumentError exception propagate so that I can handle it. Overriding ArgumentParser.error doesn't really help since methods like parse_known_args just send a message to be relayed to the user as an argument after swallowing ArgumentError (which does have useful information in its attributes). If I wanted to figure out what actually caused the exception to be raised, I'd have to parse the message, which is ugly at best. I understand that most people do want argparse to just display a message and terminate if the arguments supplied aren't useful, but there's a lot of potential in the module that is crippled outside the main use case. I have to wonder why a module that is meant to be imported would ever call sys.exit(), even if that is what the caller would normally do if presented with an exception. -- CPython 3.3.2 | Windows NT 6.2.9200 / FreeBSD 9.1
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Why is the argparse module so inflexible? Andrew Berg <robotsondrugs@gmail.com> - 2013-06-27 07:54 -0500
Re: Why is the argparse module so inflexible? Roy Smith <roy@panix.com> - 2013-06-27 09:08 -0400
Re: Why is the argparse module so inflexible? Andrew Berg <robotsondrugs@gmail.com> - 2013-06-27 08:49 -0500
Re: Why is the argparse module so inflexible? Dave Angel <davea@davea.name> - 2013-06-27 12:02 -0400
Re: Why is the argparse module so inflexible? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-27 22:49 +0000
Re: Why is the argparse module so inflexible? Cameron Simpson <cs@zip.com.au> - 2013-06-28 09:34 +1000
Re: Why is the argparse module so inflexible? Ethan Furman <ethan@stoneleaf.us> - 2013-06-28 18:36 -0700
Re: Why is the argparse module so inflexible? rusi <rustompmody@gmail.com> - 2013-06-28 21:12 -0700
Re: Why is the argparse module so inflexible? Terry Reedy <tjreedy@udel.edu> - 2013-06-29 00:37 -0400
Re: Why is the argparse module so inflexible? Roy Smith <roy@panix.com> - 2013-06-29 10:12 -0400
Re: Why is the argparse module so inflexible? Andrew Berg <robotsondrugs@gmail.com> - 2013-06-29 09:17 -0500
Re: Why is the argparse module so inflexible? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-29 05:28 +0000
Re: Why is the argparse module so inflexible? Marcin Szamotulski <mszamot@gmail.com> - 2013-06-29 13:38 +0100
Re: Why is the argparse module so inflexible? MRAB <python@mrabarnett.plus.com> - 2013-06-29 16:58 +0100
Re: Why is the argparse module so inflexible? Ethan Furman <ethan@stoneleaf.us> - 2013-06-29 12:17 -0700
Re: Why is the argparse module so inflexible? Modulok <modulok@gmail.com> - 2013-06-28 19:39 -0600
Re: Why is the argparse module so inflexible? Isaac To <isaac.to@gmail.com> - 2013-06-29 12:37 +0800
Re: Why is the argparse module so inflexible? Robert Kern <robert.kern@gmail.com> - 2013-06-27 20:47 +0100
csiph-web