I am using argparse
and I have two optional arguments:
parser.add_argument('-a', '--arg1', default=1, type=int)
parser.add_argument('-b', '--arg2', action='store_true', default=False)
Is there a way to set arg1
default value of "1" if only if arg2
is set True
?
In other word, I only want to do the following only if arg2
is set to True
:
parser.add_argument('-a', '--arg1', default=1, type=int)
Otherwise, it will be set to:
parser.add_argument('-a', '--arg1', type=int)