1

I'm aware of requiring one argument or another by putting arguments under a group and adding required as true. For example:

group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('-1', '--arg1')
group.add_argument('-2', '--arg2')

this gives a usage of script.py (-1 || -2) and is described as 'mutually exclusive' arguments: https://docs.python.org/3/library/argparse.html#mutual-exclusion

What I'm looking for is how to have: usage script.py (-1 || -2 && -3) and what is this described as/termed?

lcb
  • 87
  • 6
  • 1
    http://stackoverflow.com/questions/17909294/python-argparse-mutual-exclusive-group – Nehal J Wani Aug 04 '16 at 15:20
  • The situation in 2013 still applies - you need to write your own test after parsing. And if needed your own `usage` message. Edit your question if you need something more specific. – hpaulj Aug 04 '16 at 16:11
  • thanks, I'd hoped for a more elegant recent answer but looks like nothing newer has been implemented in the argparse module – lcb Aug 09 '16 at 20:37

0 Answers0