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


Groups > comp.lang.python > #17352

merging argparse parsers

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andrea.crotti.0@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.014
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'parser': 0.05; 'argument,': 0.09; 'modifies': 0.09; 'subclass': 0.09; 'def': 0.13; 'argument': 0.15; 'class,': 0.15; 'fancy': 0.16; 'ideas?': 0.16; 'neat': 0.16; 'received:74.125.82.174': 0.24; 'problem': 0.29; 'skip:p 30': 0.29; 'message-id:@gmail.com': 0.33; 'header :User-Agent:1': 0.33; 'there': 0.33; 'object': 0.33; 'to:addr :python-list': 0.34; 'received:74.125.82': 0.35; 'something': 0.35; 'project': 0.35; 'but': 0.37; 'received:74.125': 0.37; 'received:google.com': 0.37; 'options': 0.37; 'think': 0.37; 'received:10.0.0': 0.38; 'should': 0.39; 'to:addr:python.org': 0.40; 'alternative': 0.65; 'structures.': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=n2ajpBrJC254A6oOKOcQUQj7MI4uJoAVxNmrLgjIClI=; b=E2Y0N9Ihr9iAAjvdgLX/R4X9jK/QPTNFSR+j52iitz+JoQ/wiU16tau2YczNjf8wBa PwudvqmP194QaVXH0uexHOCGxnnU1Gh4BVnpC5PEQqC4oUNdwbDLlmb1FV0dtCfAMwOb XqmHl/MM3cpFgzi3QflHwSEno7zRi7Ei7J01w=
Date Fri, 16 Dec 2011 11:37:54 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111108 Thunderbird/8.0
MIME-Version 1.0
To python-list@python.org
Subject merging argparse parsers
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.3724.1324035481.27778.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324035481 news.xs4all.nl 6893 [2001:888:2000:d::a6]:45047
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17352

Show key headers only | View raw


I would like to have something like

merged_parser = LoggingParser() + OtherParser()

Which should create an argument parser with all the options composed.

Now for that I think I would need to subclass the argument, and something
fancy with the overloading.
The problem is that apparently there is no Argument class, but add_argument
just change the object internal data structures.

So the only alternative I see now is to do something like:
def add_project_argument(parser):
     parser.add_argument('project_path',
                         help='paths of the project to run')

which is not very neat and modifies the object in place.
Any other ideas?

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


Thread

merging argparse parsers Andrea Crotti <andrea.crotti.0@gmail.com> - 2011-12-16 11:37 +0000

csiph-web