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.p y 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_opti on("--value1",dest"va l1")
parser.add_opti on("--value2",dest"va l2")
parser.add_opti on("--value3",dest"va l3")
parser.add_opti on("-o",action="stor e",type="string ",dest="opt 1")
parser.add_opti on("-p",action="stor e",type="string ",dest="opt 2")
parser.add_opti on("-q",action="stor e",type="string ",dest="opt 3")
opts,args=parse r.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)....anyo ne know a better way?
What i enter on the command line:
C:\...>mycode.p y 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_opti on("--value1",dest"va l1")
parser.add_opti on("--value2",dest"va l2")
parser.add_opti on("--value3",dest"va l3")
parser.add_opti on("-o",action="stor e",type="string ",dest="opt 1")
parser.add_opti on("-p",action="stor e",type="string ",dest="opt 2")
parser.add_opti on("-q",action="stor e",type="string ",dest="opt 3")
opts,args=parse r.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)....anyo ne know a better way?
Comment