1

I have two flags, both of which require a value -i [value] & -k [value].

Only if I use -i importantValue, will the -k [value] flag be required.

Is it possible to specify this with argparse? If so, how?

ericg
  • 8,413
  • 9
  • 43
  • 77
  • related: http://stackoverflow.com/questions/25626109/python-argparse-conditionally-required-arguments – NightShadeQueen Jul 15 '15 at 16:06
  • and http://stackoverflow.com/questions/19414060/argparse-required-argument-y-if-x-is-present – hpaulj Jul 15 '15 at 16:17
  • To add to the earlier answers, the only thing new is that the value of `-i` matters. That's all the more reason to do your own checking after parsing. Since the user can specify `-i` after `-k`, you don't know its final value until all of the values are parsed. – hpaulj Jul 16 '15 at 00:25

0 Answers0