Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #49350

Re: Why is the argparse module so inflexible?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
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; 'scripts': 0.03; 'argument': 0.05; 'arguments': 0.09; 'caller': 0.09; 'exception,': 0.09; 'exception.': 0.09; 'feature.': 0.09; 'input,': 0.09; 'lines.': 0.09; 'parsing': 0.09; 'scripts,': 0.09; 'subject:Why': 0.09; 'subject:module': 0.09; 'abort': 0.16; 'cmd': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'received:211.29': 0.16; 'received:211.29.132': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'simpson': 0.16; 'subclass': 0.16; 'subject:argparse': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'seems': 0.21; 'command': 0.22; 'header:User-Agent:1': 0.23; 'parse': 0.24; "shouldn't": 0.24; 'cheers,': 0.24; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; 'work.': 0.31; 'catching': 0.31; 'invoke': 0.31; 'beginning': 0.33; 'subject:the': 0.34; "can't": 0.35; 'something': 0.35; 'add': 0.35; 'really': 0.36; 'raising': 0.36; 'received:com.au': 0.36; 'useful': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'behind': 0.37; 'turn': 0.37; 'received:211': 0.38; 'to:addr :python-list': 0.38; 'does': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'catch': 0.60; 'simply': 0.61; 'content-disposition:inline': 0.62; 'feeling': 0.68; 'special': 0.74; 'ethan': 0.84; 'furman': 0.84; 'karl': 0.84; 'off,': 0.84; 'shell,': 0.91
Date Fri, 28 Jun 2013 09:02:13 +1000
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: Why is the argparse module so inflexible?
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <51CC897E.5000702@stoneleaf.us>
User-Agent Mutt/1.5.21 (2010-09-15)
References <51CC897E.5000702@stoneleaf.us>
X-Optus-CM-Score 0
X-Optus-CM-Analysis v=2.0 cv=Q6eKePKa c=1 sm=1 a=wom5GMh1gUkA:10 a=I0cP0X-GMOAA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=_UKPi1JAgJMA:10 a=gJ-rYJIB6jlJU1dMyXYA:9 a=CjuIK1q_8ugA:10 a=ExiFL-q3zkAA:10 a=ChdAjXE5lkUvdteQbhpnkQ==:117
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.3943.1372375979.3114.python-list@python.org> (permalink)
Lines 28
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372375979 news.xs4all.nl 15932 [2001:888:2000:d::a6]:56692
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49350

Show key headers only | View raw


On 27Jun2013 11:50, Ethan Furman <ethan@stoneleaf.us> wrote:
| If the OP is writing an interactive shell, shouldn't `cmd` be used
| instead of `argparse`?  argparse is, after all, intended for
| argument parsing of command line scripts, not for interactive work.

This is specious.

I invoke command line scripts interactively. There's no special case here.

If argparse is raising a useful and inspectable bad argument
exception, why not let it out? Catching that argument and wrapping
it in something opaque seems unhelpful.  After all, if the caller
really wanted to abort on bad arguments the caller would simply not
catch that exception.  There's no need to transmute it into a
whole-program abort.

If Terry's assertion is that the OP has told argparse he never wants
to see bad input, how does one turn that off?

To add to the use case stats, I also subclass cmd and parse interactive
command lines. I'm beginning to be pleased I'm still using Getopt
for that instead of feeling I'm lagging behind the times.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au>

If it can't be turned off, it's not a feature. - Karl Heuer

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Why is the argparse module so inflexible? Cameron Simpson <cs@zip.com.au> - 2013-06-28 09:02 +1000

csiph-web