M
mercuryprey
Hello,
I want to do the following:
def do_load(self, arg):
sitefile = file('sitelist', 'r+', 1)
while True:
siteline = sitefile.readline()
site_rawlist = siteline.split()
sitelist[site_rawlist[0]] = site_rawlist[1:]
if len(siteline) == 0:
break
I want to load a textfile into a dictionaries and use the first word on
a line as the key for the list, then take the remaining words of the
line and make them values of the key. This doesn't work:
File "ftp.py", line 57, in do_load
sitelist[site_rawlist[0]] = site_rawlist[1:]
IndexError: list index out of range
However, it works flawlessy in another function, where I have:
def do_add(self, arg):
sitefile = file('sitelist', 'r+', 1)
act_addlist = arg.split()
sitelist[act_addlist[0]] = act_addlist[1:]
sitefile.seek(0,2)
sitefile.write(arg + "\n")
print "Written to database."
Anyone knows why it doesn't work in the first function? Help very much
appreciated.
munin
I want to do the following:
def do_load(self, arg):
sitefile = file('sitelist', 'r+', 1)
while True:
siteline = sitefile.readline()
site_rawlist = siteline.split()
sitelist[site_rawlist[0]] = site_rawlist[1:]
if len(siteline) == 0:
break
I want to load a textfile into a dictionaries and use the first word on
a line as the key for the list, then take the remaining words of the
line and make them values of the key. This doesn't work:
File "ftp.py", line 57, in do_load
sitelist[site_rawlist[0]] = site_rawlist[1:]
IndexError: list index out of range
However, it works flawlessy in another function, where I have:
def do_add(self, arg):
sitefile = file('sitelist', 'r+', 1)
act_addlist = arg.split()
sitelist[act_addlist[0]] = act_addlist[1:]
sitefile.seek(0,2)
sitefile.write(arg + "\n")
print "Written to database."
Anyone knows why it doesn't work in the first function? Help very much
appreciated.
munin