getopt index out of range
ntwrkd at gmail.com
Wed Feb 11 17:27:13 EST 2009
Keep your threadiquette to yourself.
On Wed, Feb 11, 2009 at 1:48 PM, John Machin <sjmachin at lexicon.net> wrote:
> On Feb 11, 6:16 am, Matthew Sacks <ntw... at gmail.com> wrote:
>> 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
>> adminServerURL = optlist
>> action = optlist
>> targets = optlist
>> appDir = optlist
> As you have been told, it is blowing up on index 0. That is because
> optlist is empty (in this case). optlist can contain anything from 0
> items to as many as your user cares to type in. It is NOT limited to
> the number of different options specified in the getopt call; consider
> the case where the arg string is "--action add --action del". Further,
> the contents of optlist are presented in the order they are typed in
> by the user.
> Consequently any attempt to give meaningful names to option values
> using constant subscripting of optlist is prima facie an utter
> It is a mind-bogglingly astonishing utter nonsense given the lengthy
> conversation about getopt that we had in another thread yesterday.
> What on earth are you doing???
More information about the Python-list