Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python argparse one or the other

import argparse

parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group(required=True) # <---
group.add_argument('--foo',action=.....)
group.add_argument('--bar',action=.....)
args = parser.parse_args()

# With this group (mutually_exclusive) one can specify that only one
# of the added arguments should be accepted.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #argparse
ADD COMMENT
Topic
Name
6+1 =