class People:
def __init__(self, fname=None, lname=None, age=None, gender=None):
self.fname = fname
self.lname = lname
self.age = age
self.gender = gender
def display(self):
print self.fname
people = [People('John','W Cooper',23,'Male'),
People('James','W Cooper',30,'Male'),
People('Kate','W Cooper',20,'Female')]
f = open("abc.txt", "w")
for person in people:
f.write( person.fname +","+ person.lname +","+ str(person.age) +","+ person.gender + '\n' )
person.display()
f.close()
5
solved How to populate Objects in a an existing file [closed]