I am using argparse
in Python 3. My requirement is to support the following 3 use-cases:
$ python3 foo.py --test <== results e.g. in True
$ python3 foo.py --test=foo <== results in foo
$ python3 foo.py <== results in arg.test is None or False
I found store_true
, and store
, but can't find any configuration where I can achieve the following arg list as mentioned above. Either it wants to have a parameter, or None. Both seems not to work. Is there any way to make a argument optional?