Cross-argument validation in argparse
问题 I'm looking for a Pythonic way to validate arguments when their validation logically depends on the value(s) parsed from other argument(s). Here's a simple example: parser.add_argument( '--animal', choices=['raccoon', 'giraffe', 'snake'], default='raccoon', ) parser.add_argument( '--with-shoes', action='store_true', ) In this case, parsing this command should cause an error: my_script.py --animal snake --with-shoes Adding a mutually exclusive group doesn't seem to help here, as the other