Argparse argument with an additional value

Viewed 571

I've created an argparse argument, which supports only 3 choices:

parser.add_argument('--param', default='ch1', choices=('ch1', 'ch2', 'ch3'), help='message')

But I have to add a new special choice ch4 which will require an additional value. I.e., my program should support such inputs:

./prog.py --param ch1
./prog.py --param ch2 # or ch3
./prog.py --param ch4='some_additional_variable'

How I can realize this (or some similar behavior)?

2 Answers
Related