I would like to parse arguments passed from the command line with the prefix option as such :
python myApp.y -f file.xml
I am using python 2.6.6 so I cannot use argparse.
And I would like to make it a bit more generic and scalable than
arg1 = sys.argv[1]
arg2 = sys.argv[2]
And then use ifs to check the values and whether they have been provided.
You could use
optparse, butargparseis available and can easily be installed on python 2.6.Here’s how you’d do it with argparse:
Or with optparse: