title: Save dictionary of class instances in a file?
body: <p>Consider following class and function:</p>
  
  <pre><code>class DictEntry:
      term = ""
      docFreq = 0
      termFreq = 0
      postingList = []
  
      def __init__(self, t, df, tf, pl):
          self.term = t
          self.docFreq = df
          self.termFreq = tf
          self.postingList = pl
  
  def insertDict(docId, token, termFreq, dictionary):
      entry = dictionary.get(token)
      if entry is None:
          postList = []
          entry = DictEntry(token, 0, 0, postList)
          dictionary[token] = entry
      entry.docFreq +=1
      entry.postingList.extend([docId])
      entry.termFreq += termFreq
  </code></pre>
  
  <p>The function <code>insertDict</code> creates an object for a key if it's not in dictionary.</p>
  
  <p>In main, I need to save <code>dictionary</code> with keys and class instances to a file.</p>