Skip to content

Instantly share code, notes, and snippets.

@hisplan
Created November 5, 2015 18:46
Show Gist options
  • Save hisplan/6cc17fa173f063ced4eb to your computer and use it in GitHub Desktop.
Save hisplan/6cc17fa173f063ced4eb to your computer and use it in GitHub Desktop.
Python argparse mutually exclusive group
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument('--foo', action='store_true')
group.add_argument('--bar', action='store_false')
settings = parser.parse_args()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment