I have a set of arguments that can logically be separated in 2 groups:
A1
, A2
, A3
, etc.
mutually_exclusive_group
is a simple xor
logic test. You could define 2 separate groups, but it does not provide any means of working across/between the groups.
I have worked on a patch to allow more complex logic and nested groups. The testing logic isn't that bad, but designing a good user interface is tricky, as is creating a meaningful usage
line. So that enhancement probably will never see production.
Testing arguments after parsing is perfectly good. It only becomes tricky if you can't distinguish between attributes with default values and ones the usage gave you - so the default default None
is best. argparse
is primarily a parser, figuring out what the user wants. Whether they want something legit (beyond the simplest cases) is a different issue.