title: Pickle won't save just the object instance
body: <p>I'm working with text classification using NLTK and since it would take a long time to re-train my classifier everytime I want to use it I've been trying to use pickle to save an instance of the classifier that I can just call up later.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>classifier = nltk.NaiveBayesClassifier.train(training_set)
  filehandler = open("class.pickle","wb")
  pickle.dump( classifier, filehandler )
  filehandler.close()
  </code></pre>
  
  <p>However, when I pull up the classifier in another program:</p>
  
  <pre><code>classifier = pickle.load(open("class.pickle","rb"))
  </code></pre>
  
  <p>and run the program, it doesn't just open the classifier object, but it runs the entire file as well, and in doing so retrains everything and runs code that doesn't need to be run (such as print statements). </p>
  
  <p>edit: It seems the problem was I was also importing another function from the file I created my classifier in. I moved this function to my new file and re-ran it and it works fine now.</p>