argparse - 3rd arg only valid for one of two mutually exclusive args?

Loris Bennett loris.bennett at fu-berlin.de
Wed Nov 3 08:36:07 EDT 2021


Hi,

With argparse's add_mutually_exclusive_group() I can add mutually
exclusive args, but how do I deal with a 3rd arg which only makes sense
for one of the mutually exclusive args?

More generally I suppose I am interested in having something like

  [ --foo (--foobar) | --bar (--barfoo) ]

if that makes it any clearer.

I have seen subcommand suggested as a way of doing this, but that
doesn't seem like a very good fit for my use-case.  Is there a more
argument-orientated alternative?

Cheers,

Loris

-- 
This signature is currently under construction.


More information about the Python-list mailing list