title: Pickle with custom classes
body: <p>Suppose I have a simple python class definition in a file myClass.py</p>
  
  <pre><code>class Test:
      A = []
  </code></pre>
  
  <p>And I also have two test scripts. The first script creates an object of type Test, populates the array A, and pickles the result to a file. It immediately unpickles it from the file and the array is still populated.
  The second script just unpickles from the file, and <strong>the array is not populated (i.e. A == []). Why is this?</strong></p>
  
  <p>test1.py</p>
  
  <pre><code>import myClass
  import pickle
  
  x = myClass.Test()
  
  for i in xrange(5):
      x.A.append(i)
  
  f = open('data', 'w')
  pickle.dump(x,f)
  f.close()
  
  f = open('data')
  y = pickle.load(f)
  f.close
  
  print y.A
  </code></pre>
  
  <p>and test2.py</p>
  
  <pre><code>import myClass
  import pickle
  
  f = open('data')
  y = pickle.load(f)
  f.close
  
  print y.A
  </code></pre>