Q:

How do I append to a new object?

I have this function in python 3 that works almost as I want it to work:
def read_people_from_file(filename):
    """Function that reads a file and adds them as persons"""
    print("reading file")
    try:
        with open(filename, 'rU') as f:
            contents = f.readlines()
    except IOError:
       print("Error: Can not find file or read data")
       sys.exit(1)

    #Remove blank lines
    new_contents = []
    for line in contents:
        if not line.strip():
            continue
        else:
            new_contents.append(line)

    #Remove instructions from file
    del new_contents[0:3]

    #Create persons (--> Here is my problem/question! <--)
    person = 1*[None]
    person[0] = Person()
    person[0] = Person("Abraham", "m", 34, 1, 140, 0.9, 90, 0.9, 0.9)
    for line in new_contents:
        words = line.split()
        person.append(Person(words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8]))
    return person

In the last chunk of code, below "#Create persons", is a thing that I have not figured out how to do.
How do I create the empty list of persons and then add persons from the file?
If I remove the hard coded person named "Abraham", my code does not work.
The file is a text file with one person per row with the attributes coming after the name.
Part of the Person class looks like this:
class Person:
def __init__(self, name=None, gender=None, age=int(100 or 0), beauty=int(0), intelligence=int(0), humor=int(0), wealth=int(0), sexiness=int(0), education=int(0)):
    self.name = name
    self.gender = gender
    self.age = age
    self.beauty = beauty
    self.intelligence = intelligence
    self.humor = humor
    self.wealth = wealth
    self.sexiness = sexiness
    self.education = education

I hope that the above code is self explanatory.
I suspect that there is some more pythonian way of doing what I want.
Any help is appreciated.

A:

You can do
persons = []
...
for line in new_contents:
    words = line.split()
    persons.append(Person(...))

