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: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On 27Jun2013 11:50, Ethan Furman 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 If it can't be turned off, it's not a feature. - Karl Heuer