Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #17832
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!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 | <jsf80238@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.113 |
| X-Spam-Level | * |
| X-Spam-Evidence | '*H*': 0.77; '*S*': 0.00; 'parser': 0.05; 'argument': 0.15; 'this:': 0.16; '>>>': 0.18; 'header:In-Reply-To:1': 0.22; 'skip:m 30': 0.24; 'sender:addr:gmail.com': 0.25; 'message- id:@mail.gmail.com': 0.28; 'parent': 0.30; 'url:library': 0.31; 'received:209.85.160': 0.33; 'to:addr:python-list': 0.34; 'something': 0.35; 'received:209.85.160.46': 0.35; 'received:mail- pw0-f46.google.com': 0.35; 'url:python': 0.36; 'received:google.com': 0.37; 'options': 0.37; 'think': 0.37; 'received:209.85': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'should': 0.39; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'more': 0.61; 'your': 0.61; 'become': 0.69; 'child,': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=jXURFAEZkr6x4cKBQdtq8b2cj82rfTS4HQFF9CLaymc=; b=eZ1f3i0ks8Ah8amAHcjPtRdyxHN0bMtkPfoooWsDjI+dn9hxuEt/IxEHYaTrupG8ET hwrZ1FIUF44UE1/AZqtM6hBjL6VZTget+9d6W4EOj/llnRpZu1rU4kgrhKHTqdJzIEB/ xWpCbvbFoEs+uOUPL2O0h/844El5uJ3XKyPq4= |
| MIME-Version | 1.0 |
| Sender | jsf80238@gmail.com |
| In-Reply-To | <4EEB2D92.10200@gmail.com> |
| References | <4EEB2D92.10200@gmail.com> |
| Date | Sat, 24 Dec 2011 05:34:46 +0000 |
| X-Google-Sender-Auth | V8sGkDQ4m68zqzi_gT6kUkOKPD4 |
| Subject | Re: merging argparse parsers |
| From | Jason Friedman <jason@powerpull.net> |
| To | python-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| 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.4043.1324704889.27778.python-list@python.org> (permalink) |
| Lines | 18 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1324704889 news.xs4all.nl 6860 [2001:888:2000:d::a6]:45866 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:17832 |
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.
>
I have used parent parsers.
http://docs.python.org/py3k/library/argparse.html#parents
I think in your case merged_parser would become more of a child, like this:
>>> mom_parser = argparse.ArgumentParser(add_help=False)
>>> mom_parser.add_argument('--arg1', type=int)
>>> dad_parser = argparse.ArgumentParser(add_help=False)
>>> dad_parser.add_argument('--arg2', type=int)
>>> child_parser = argparse.ArgumentParser(parents=[mom_parser, dad_parser])
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: merging argparse parsers Jason Friedman <jason@powerpull.net> - 2011-12-24 05:34 +0000
csiph-web