Python class instance variables disappear
<p>I define the response class like this:</p>

<pre><code>class Response(object):
    def __index__(self):
        self.country = ""
        self.time_human = ""
        self.time_utc = ""
        self.text = ""
        self.time_object = None
        self.clean_word_list = []

    def parse_line(self, line):
        if 'text:' in line[:10]:
            self.text = line[7:].strip()
        elif 'country: ' in line[:9]:
            self.country = line[8:].strip()
        elif 'time_human: ' in line[:15]:
            self.time_human = line[12:].strip()
        elif 'time_utc: ' in line[:15]:
            self.time_utc = int(line[10:].strip())
            self.time_object = datetime.fromtimestamp(self.time_utc)
</code></pre>

<p>I then have a method that reads lines from a text file and assigns the proper value to the response:</p>

<pre><code>class file_importer(object):
    def __init__(self, file_name):
        self.file_name = file_name

def get_responses_from_file(self):
    directory = DIRECTORY_TO_FILE
    formatted_filename = directory + self.file_name
    file = open(formatted_filename, 'r')
    response = Response()
    response_list = []
    for line in file:
        if line[0] == '*':
            response_list.append(response)
            response = Response()
        else:
            response.parse_line(line)
    return response_list
</code></pre>

<p>But the response_list that the get_responses_from_file() returns is a list of responses that do not have a response.clean_word_list attribute.  What happened?</p>

<p>It has to be <code>__init__</code> instead of <code>__index__</code> in your <code>Response</code> class</p>

python class