from Globals import MAX class MyContacts: def __init__(self): self.FILENAME = "contacts.txt" self.FILE_MODE = "r" self.permContactList = [] self.readFromFile() def displayContacts(self): i = 0 while (i < len(self.permContactList)): print(self.permContactList[i]) i = i + 1 def readFromFile(self): done = False count = 0 inputFile = open(self.FILENAME,self.FILE_MODE) # Notice how the display is double spaced (one newline # from print() the other is read in from the file). while (done == False): line = inputFile.readline() if ((line == "") or (count >= (MAX))): done = True else: self.permContactList.append(line) count = count + 1 inputFile.close()