Did you get any answers?
One way to debug python exceptions is to move (or temporarily copy for debugging) the code from the try block. You will get a complete trace.
And, of course, another way is to reduce the test case. Here I reduced the problems to three lines and tried the solution targeted at @ s.lott (using "f:" in the getopts call) and also finally show how the call behaves with some different test data: / p>
$ cat x1.py import sys, getopt opts, args = getopt.getopt(sys.argv[1:],'fdmse:d',['files=','data-source=','mode=','start','end']) print "opts=", opts, "args=", args $ python x1.py -f=dummy.csv argblah Traceback (most recent call last): File "x1.py", line 2, in <module> opts, args = getopt.getopt(sys.argv[1:],'fdmse:d',['files=','data-source=','mode=','start','end']) File "/usr/lib/python2.6/getopt.py", line 91, in getopt opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:]) File "/usr/lib/python2.6/getopt.py", line 191, in do_shorts if short_has_arg(opt, shortopts): File "/usr/lib/python2.6/getopt.py", line 207, in short_has_arg raise GetoptError('option -%s not recognized' % opt, opt) getopt.GetoptError: option -= not recognized $ sed 's/fdm/f:dm/' <x1.py >x2.py $ diff x1.py x2.py 2c2 < opts, args = getopt.getopt(sys.argv[1:],'fdmse:d',['files=','data-source=','mode=','start','end']) --- > opts, args = getopt.getopt(sys.argv[1:],'f:dmse:d',['files=','data-source=','mode=','start','end']) $ python x2.py -f=dummy.csv argblah opts= [('-f', '=dummy.csv')] args= ['argblah'] $ python x1.py -f dummy.csv argblah opts= [('-f', '')] args= ['dummy.csv', 'argblah']