I want to achive next behaviour:
python script.py
> my_arg is None
python script.py --my-arg
> my_arg is "default"
python script.py --my-arg some_value
> my_arg is "some_value"
How to configure this argument for Argparser?
What I've tried so far:
#!/usr/bin/env python
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--my-argument', nargs='?', default='default')
args = parser.parse_args()
print(args.my_argument)
But for test.py
I've got default