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


Groups > comp.lang.python > #49354

Re: Why is the argparse module so inflexible?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; 'argument': 0.05; 'lines.': 0.09; 'optparse': 0.09; 'override': 0.09; 'parsing': 0.09; 'scripts,': 0.09; 'subject:Why': 0.09; 'subject:module': 0.09; '-tkc': 0.16; 'cmd': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'libraries.': 0.16; "method's": 0.16; 'simpson': 0.16; 'subclass': 0.16; 'subject:argparse': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'command': 0.22; 'parse': 0.24; "shouldn't": 0.24; 'header:In-Reply-To:1': 0.27; 'raise': 0.29; "i'm": 0.30; 'work.': 0.31; 'gives': 0.31; 'code': 0.31; 'invoke': 0.31; 'beginning': 0.33; 'older': 0.33; 'subject:the': 0.34; 'add': 0.35; 'combination': 0.36; 'charset :us-ascii': 0.36; 'subject:?': 0.36; 'behind': 0.37; 'too': 0.37; 'to:addr:python-list': 0.38; 'ability': 0.39; 'to:addr:python.org': 0.39; 'feeling': 0.68; 'default': 0.69; 'special': 0.74; 'behavior': 0.77; 'ethan': 0.84; 'furman': 0.84; 'received:50.22': 0.84; 'shell,': 0.91; 'choice.': 0.93
Date Thu, 27 Jun 2013 19:22:21 -0500
From Tim Chase <python.list@tim.thechases.com>
To python-list@python.org
Subject Re: Why is the argparse module so inflexible?
In-Reply-To <20130627230213.GA22992@cskk.homeip.net>
References <51CC897E.5000702@stoneleaf.us> <20130627230213.GA22992@cskk.homeip.net>
X-Mailer Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
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.3946.1372378844.3114.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1372378844 news.xs4all.nl 15874 [2001:888:2000:d::a6]:49308
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:49354

Show key headers only | View raw


On 2013-06-28 09:02, Cameron Simpson wrote:
> 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.
> 
> I invoke command line scripts interactively. There's no special
> case here.
> 
> 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.

I too have several small utilities that use a combination of cmd.Cmd,
shlex.shlex(), and command-processing libraries.  However, much like
Cameron's code using getopt, my older code is still using optparse
which gives me the ability to override the error() method's default
sys.exit() behavior and instead raise the exception of your choice.

-tkc


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


Thread

Re: Why is the argparse module so inflexible? Tim Chase <python.list@tim.thechases.com> - 2013-06-27 19:22 -0500

csiph-web