I have created a piece of python code; however, I want to execute it from the command line with some arguments and options. What I have so far works ok (with the exception that i CANNOT enter in negative values for the arguments -- and i need to be able to!) How can i better write this code?
What i enter on the command line:
C:\...>mycode.py arg1 arg2 arg3 -o filename -p filename -q filename (this is 3 arguments and 3 options)
What my code does (works with exception of negatives):
import sys
parser=optparse.OptionParser()
parser.add_option("--value1",dest"val1")
parser.add_option("--value2",dest"val2")
parser.add_option("--value3",dest"val3")
parser.add_option("-o",action="store",type="string",dest="opt1")
parser.add_option("-p",action="store",type="string",dest="opt2")
parser.add_option("-q",action="store",type="string",dest="opt3")
opts,args=parser.parse_args()
Help with this please...Again, I want to correctly do the arguments and options on the command line and be able to input negative values for an argument if needed. Again, what i have works (except for negative values)....anyone know a better way?