getopt index out of range

Matthew Sacks ntwrkd at gmail.com
Tue Feb 10 14:16:23 EST 2009


Hi List,
I am getting an index out of range error when trying to parse with getopt.
Probably something simple. Any suggestions are appreciated

optlist, args = getopt.getopt(sys.argv[1:], 'h', ['connectPassword=',
'adminServerURL=', 'action=', 'targets=', 'appDir='])


#Assign Opts
connectPassword = optlist[0][1]
adminServerURL = optlist[1][1]
action = optlist[2][1]
targets = optlist[3][1]
appDir = optlist[4][1]

#this statement never gets executed
print "Args: " + connectPassword + " " + adminServerURL + " " + action
+ " " + targets + " " + appDir

  File "/home/msacks/untitled4.py", line 23, in ?
IndexError: index out of range: 0

TIA



More information about the Python-list mailing list