I'm trying to solve a problem with python's argparse function
What I would like to achieve is, that if -k argument is specified, it's set to its default value (let's say 5), however if -k=3 is set, 'k' now contains 3...
Here is an example:
python3 test.py -k
Namespace(k==5)
python3 test.py -k=3
Namespace(k==3)
Is it possible to get something like this ?
test.py
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-k ', metavar='n', type=int, default=5, dest='number')
args = parser.parse_args()
print(args)
Thanks in advance
-k? What value do you want?