This is a very basic example of setting up argparse
:
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--input_a", type=int, default=0,
help="first_input")
parser.add_argument("--input_b", type=int,
help="second_input")
args = parser.parse_args()
The default value for an argument is the value that it takes if it's not provided explicitly when I call the script.
I want to modify the code above in order to have for input_b
more than one default value. To be more clear, I want that the default value of input_b
depends on the value of input_a
. Is this feature covered by argparse
library or should I make a workaround after the parsing?
Bonus Question
To further extend the question, could I set the default value of one argument on the base of more than one other argument?