Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python argparse only allow certain values

...
parser.add_argument('--val',
                    choices=['a', 'b', 'c'],
                    help='Special testing value')

args = parser.parse_args(sys.argv[1:])
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #argparse #values
ADD COMMENT
Topic
Name
4+2 =