Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'arguments': 0.09; 'iterate': 0.09; 'solution,': 0.09; 'subject:parsing': 0.09; '*before*': 0.16; '>on': 0.16; 'although,': 0.16; 'alvarez': 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:cskk.homeip.net': 0.16; 'received:homeip.net': 0.16; 'received:optusnet.com.au': 0.16; 'received:syd.optusnet.com.au': 0.16; 'reedy': 0.16; 'simpson': 0.16; 'subject:argparse': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'first.': 0.19; 'options.': 0.19; 'user.': 0.19; 'header:User-Agent:1': 0.23; 'config': 0.24; 'specify': 0.24; 'cheers,': 0.24; 'environment': 0.24; 'options': 0.25; 'first,': 0.26; 'header:In-Reply-To:1': 0.27; "i'm": 0.30; "skip:' 10": 0.31; 'invoke': 0.31; 'file': 0.32; 'option': 0.32; 'could': 0.34; 'there': 0.35; 'received:com.au': 0.36; 'sequence': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'turn': 0.37; 'received:211': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'expect': 0.39; 'aside': 0.39; 'to:addr:python.org': 0.39; 'remove': 0.60; 'content-disposition:inline': 0.62; 'forward': 0.65; 'commercial': 0.71; 'eduardo': 0.84 Date: Sun, 1 Sep 2013 09:44:56 +1000 From: Cameron Simpson To: python-list@python.org Subject: Re: argparse - specify order of argument parsing? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) References: X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=bpB1Wiqi c=1 sm=1 tr=0 a=YuQlxtEQCowy2cfE5kc7TA==:117 a=YuQlxtEQCowy2cfE5kc7TA==:17 a=ZtCCktOnAAAA:8 a=PO7r1zJSAAAA:8 a=LcaDllckn3IA:10 a=GJwq_a9B6GkA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=8AHkEIZyAAAA:8 a=wtzmShFqDJsA:10 a=bbgiQaK_SnmG6Yv59sUA:9 a=CjuIK1q_8ugA:10 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: 1377994347 news.xs4all.nl 15912 [2001:888:2000:d::a6]:33670 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:53385 On 31Aug2013 14:17, Terry Reedy wrote: | On 8/31/2013 2:13 PM, Terry Reedy wrote: | >On 8/31/2013 1:11 PM, Eduardo Alvarez wrote: | >>When using argparse, is there a way to specify in what order arguments | >>get parsed? | > | >I expect argparse to forward iterate the sequence of arguments that it | >receives. | | Aside from the environment variable solution, you could search | sys.argv for 'config=filename' and remove it and process it *before* | you invoke argparse. Although, speaking for myself, I like options to have effect as encountered: some-cmd -a --no-foo Would turn on "all" options then turn off "foo". Hard to do if you look for "more important" options and then less important options. I'm personally against out-of-order option handling; it confuses things for the user. If you (as the user) need the config file to be known first, put it first. Cheers, -- Cameron Simpson You wouldn't... ...but you KNOW you could. - Original V65 Commercial