Storing an object of a class then calling a function in that object <p>I have a class like this (scaled down)</p> <pre><code>class FileAndWriter(object): def __init__(self, symbol, start_dt_str): self.data = [] self.fileName = symbol.replace("/", "") + '-' + start_dt_str + '.csv' self.file = open(self.fileName, 'ab') self.csvWiter = csv.writer(self.file, delimiter=',') # , quoting=csv. QUOTE_ALL def write_rows(self): self.csvWiter.writerows(self.data) self.file.flush() def appendData(dataMsg): try: self.data.append(dataMsg) if len(self.data) &gt; 100: self.write_rows(self.data) self.data = [] except: print "appendData error:", sys.exc_info()[0] </code></pre> <p>I have another class that composes that class like this. <code>update</code> is a callback function of Observer:</p> <pre><code>class SymbolWriter(Observer): def __init__(self, symbol, sd, ed): self.writers = {} self.symbol = symbol self.start_date = sd self.end_date = ed for single_date in daterange(self.start_date, self.end_date): single_date_str = single_date.strftime('%Y%m%d') faw = FileAndWriter(self.symbol, single_date_str) print 'FAW ', single_date_str self.writers[single_date_str] = faw def update(self, dataMsg): try: today = datetime.datetime.utcnow() today_str = today.strftime('%Y%m%d') print today_str if today_str in self.writers: #print 'Writting' faw = self.writers[today_str] if faw is not None: faw.appendData(dataMsg) except: print "update error:", sys.exc_info()[0] </code></pre> <p>It excepts on <code>faw = self.writers[today_str]</code> with <code>update error: &lt;type 'exceptions.TypeError'&gt;</code></p> <p>How does one store an object in a dictionary and call a member function? Or is there something else I am not noticing?</p>