Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51973
| From | "Joseph L. Casale" <jcasale@activenetwerx.com> |
|---|---|
| Subject | RE: [argparse] mutually exclusive group with 2 sets of options |
| Date | 2013-08-05 17:11 +0000 |
| References | <51fdb81b$0$2423$426a74cc@news.free.fr> <6db08670-52e8-4ca2-aff4-82d611a29da6@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.215.1375722699.1251.python-list@python.org> (permalink) |
> 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 argparse 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 docopt get included... jlc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-04 04:10 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-05 04:05 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Joshua Landau <joshua@landau.ws> - 2013-08-05 04:53 +0100
Re: [argparse] mutually exclusive group with 2 sets of options Miki Tebeka <miki.tebeka@gmail.com> - 2013-08-05 07:11 -0700
RE: [argparse] mutually exclusive group with 2 sets of options "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-08-05 17:11 +0000
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-06 00:13 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Rafael Durán Castañeda <rafadurancastaneda@gmail.com> - 2013-08-05 22:01 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-06 00:34 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-07 01:18 +0200
Re: [argparse] mutually exclusive group with 2 sets of options Francois Lafont <francois.lafont@nospam.invalid> - 2013-08-07 01:36 +0200
RE: [argparse] mutually exclusive group with 2 sets of options "Joseph L. Casale" <jcasale@activenetwerx.com> - 2013-08-05 22:15 +0000
csiph-web