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


Groups > comp.lang.python > #33861

argparse -- mutually exclusive sets of arguments?

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject argparse -- mutually exclusive sets of arguments?
Date 2012-11-23 13:46 -0500
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-DDAE52.13462523112012@news.panix.com> (permalink)

Show all headers | View raw


My command either takes two positional arguments (in which case, both 
are required):

$ command foo bar

or the name of a config file (in which case, the positional arguments 
are forbidden):

$ command --config file

How can I represent this with argparse; add_mutually_exclusive_group() 
isn't quite the right thing.  It could specify that foo and --config are 
mutually exclusive, but not (as far as I can see) the more complicated 
logic described above.

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


Thread

argparse -- mutually exclusive sets of arguments? Roy Smith <roy@panix.com> - 2012-11-23 13:46 -0500
  Re: argparse -- mutually exclusive sets of arguments? Terry Reedy <tjreedy@udel.edu> - 2012-11-23 13:56 -0500
  Re: argparse -- mutually exclusive sets of arguments? Ian Kelly <ian.g.kelly@gmail.com> - 2012-11-23 18:07 -0700

csiph-web