title: pickle python Class instance
body: <p>I have a simple class to just store data that's associated to a circuit board like this :</p>
  
  <pre><code>class boardClass():
  
      def __init__(self,boardName):
          self.__name=boardName
          self.__boardMappings= {boardName:{
                                    'FastMode':
                                    {'CPU_A':{'mipi':[], 'gpen':[]},
                                     'CPU_B':{'mipi':[], 'gpen':[]}
  
                                    'SlowMode':
                                    {'CPU_A':{'mipi':[], 'gpen':[]},
                                     'CPU_B':{'mipi':[], 'gpen':[]}                                   
                                    }
                                   }                       
                                 }
  
  
      def setMode(self, board, mode, cpu,mipi,gpen):
          self.__boardMappings[board][mode][cpu]['mipi']=mipi
          self.__boardMappings[board][mode][cpu]['gpen']=gpen
  
      def getName(self):
          return self.__name
  </code></pre>
  
  <p>I use pickle in another class to store the <code>boardClass</code> data in file and later read them:</p>
  
  <pre><code>def onSave(self,boardName):
          board=boardClass.boardClass(boardName)
          name=boardName+".brd"
          file=open(name,"wb")            
          pickle.dump(board,file)                        
          loadedBoard= pickle.load( open( file, "rb" ))            
          print "Loaded board name is : ",loadedBoard.getName()
  </code></pre>
  
  <p>When I call <code>onSave()</code> method to pickle the boardClass, it gives several errors ending with this at end:</p>
  
  <pre><code>File "C:\Python27\lib\copy_reg.py", line 70, in _reduce_ex
  raise TypeError, "can't pickle %s objects" % base.__name__
  TypeError: can't pickle PySwigObject objects
  </code></pre>
  
  <p>This boardClass is very simple container. Why can't it be pickled?</p>