Python argparse conditional requirements
How do I set up argparse as follows: if -2 is on the command line, no other arguments are required if -2 is not on the command line, -3 and -4 arguments are required For example, -2 [good] -3 a -4 b [good] -3 a [not good, -4 required] -2 -5 c [good] -2 -3 a [good] There are a number of similar questions here, but either they don't address this situation or I don't understand. Python 2.7 if that matters. A subparser (as suggested in comments) might work. Another alternative (since mutually_exclusive_group can't quite do this) is just to code it manually, as it were: import argparse def main():