My code creats only the last instance times len(list) how can i change this to create every instance separatly? 😐
@staticmethod
def impWords():
tempFile = open('import.txt','r+')
tempFile1 = re.findall(r'\w+', tempFile.read())
tempFile.close()
for i in range(0,len(tempFile1)):
word.ID = i
word.data = tempFile1[i]
word.points = 0
Repo.words.append(word)
word.prt(word)
print str(Repo.words)
UI.Controller.adminMenu()
Assuming that
wordis an instance ofWord, you should create a new one in each iteration, like this:Now if your
Wordclass__init__takesID,dataandpointsas parameters, andRepo.wordsis a list you can reduce that to: