So I am trying to implement argparse in my Python code.
I want to have lets say 4 possible arguments that could be passed. But, if I choose the fourth then I would need an additional argument, but I can't implement this.
parser = argparse.ArgumentParser(description='Testing arguments')
parser.add_argument("--a", action="store_true")
parser.add_argument("--b", action="store_true")
parser.add_argument("--c", action="store_true")
parser.add_argument("--d", action="store_true")
args = parser.parse_args()
Example:
python3 mycode.py --a #no further argument needed
python3 mycode.py --d further_argument # further argument needed
I have read some of the posts on Stackoverflow, but I couldn't really find the thing I need.