Allowing specific values for an Argparse argument [duplicate]
An argparse argument can be limited to specific values with the choices
parameter:
...
parser.add_argument('--val',
choices=['a', 'b', 'c'],
help='Special testing value')
args = parser.parse_args(sys.argv[1:])
See the docs for more details.