Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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; 'subject:: [': 0.04; 'subject:group': 0.05; 'args': 0.07; 'incompatible': 0.07; 'params': 0.09; 'parsed': 0.09; 'parsing': 0.09; 'sub': 0.09; 'cli': 0.16; 'conditional': 0.16; 'declared': 0.16; 'goal,': 0.16; 'omitting': 0.16; 'ops': 0.16; 'received:172.18.0': 0.16; 'subject:argparse': 0.16; 'subject:options': 0.16; 'followed': 0.16; 'typing': 0.19; 'subject:] ': 0.20; 'code,': 0.22; 'tests': 0.22; 'to:name:python-list@python.org': 0.22; 'install': 0.23; 'certainly': 0.24; "i've": 0.25; 'performing': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'testing': 0.29; 'mode': 0.30; 'waste': 0.30; 'probably': 0.32; 'url:python': 0.33; "i'd": 0.34; 'problem': 0.35; 'subject:with': 0.35; 'something': 0.35; 'charset :us-ascii': 0.36; 'similar': 0.36; 'url:org': 0.36; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'commands': 0.60; 'received:unknown': 0.61; "you're": 0.61; 'love': 0.65; 'here': 0.66; 'between': 0.67; 'tough': 0.93 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=PW5KkOyi2N+7koGLNuH5QW2TYwO584XWNobLzFE45Rc= c=1 sm=1 a=CRTDazI5n6YA:10 a=bMjXrhc6l3kA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=kj9zAlcOel0A:10 a=xqWC_Br6kY4A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=8AHkEIZyAAAA:8 a=hryfGH_EDMI4JriAw5oA:9 a=CjuIK1q_8ugA:10 a=dTQCBY7ILbYA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 From: "Joseph L. Casale" To: "python-list@python.org" Subject: RE: [argparse] mutually exclusive group with 2 sets of options Thread-Topic: [argparse] mutually exclusive group with 2 sets of options Thread-Index: AQHOkLjcN8jSCPYJrk+6yEPX8qUb5JmHDl2A///IOqA= Date: Mon, 5 Aug 2013 17:11:30 +0000 References: <51fdb81b$0$2423$426a74cc@news.free.fr> <6db08670-52e8-4ca2-aff4-82d611a29da6@googlegroups.com> In-Reply-To: <6db08670-52e8-4ca2-aff4-82d611a29da6@googlegroups.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.18.0.200] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375722699 news.xs4all.nl 16010 [2001:888:2000:d::a6]:53152 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:51973 > You can probably do something similar using sub commands > (http://docs.python.org/2/library/argparse.html#sub-commands). The problem here is that argparse does not pass the subparser into the parsed args and shared args between subparsers need to be declared each time. Come execution time, when you have shared args you end up testing for various incantations of the invoked code, you're better off omitting subparsers and performing conditional tests after parsing for incompatible combinations. It's a waste of typing to write out a mode followed by params to achieve the ops goal, I've hit the same limitation. Certainly a weakness of argpars= e in my opinion. It's also a tough sell to force a user to install a package = just for the cli if you go with docopt. I'd love to see argparse expand or docop= t get included... jlc