I write my scripts in python and run them with cmd by typing in:
C:\> python script.py
Some of my scripts contain separate algorithms and methods which are called based on a flag. Now I would like to pass the flag through cmd directly rather than having to go into the script and change the flag prior to run, I want something similar to:
C:\> python script.py -algorithm=2
I have read that people use sys.argv for almost similar purposes however reading the manuals and forums I couldn't understand how it works.
parser = argparse.ArgumentParser()andparser.add_argument(('--Algorithm")andargs = parser.parse_args()in my script and then in cmd type inC:\> python script.py --Algorithm=2so that Algorithm is set to 2 and the python script will run tasks associated with algoritm 2?