title: Python inheritance pattern - how to handle deserialization
body: <p>Say we want to serialize <code>B</code> below:</p>
  
  <pre><code>import json
  class A:
      def __init__(self):
          self.a = 1
      @classmethod
      def serialize(cls, t):
          with open('temp_A.json', 'wb') as f:
              json.dump({'a':t.a}, f)
      @classmethod
      def deserialize(cls):
          with open('temp_A.json', 'rb') as f:
              d = json.load(f)
              obj = A()
              obj.a = d['a']
              return obj
  
  class B(A):
      def __init__(self):
          super(B, self).__init__()
          self.b = 2
      @classmethod
      def serialize(cls, t):
          with open('temp_B.json', 'wb') as f:
              json.dump({'b':t.b}, f)
      @classmethod
      def deserialize(cls):
          with open('temp_B.json', 'rb') as f:
              d = json.load(f)
              obj = B()
              obj.b = d['b']
              a = A.deserialize()
              #### IMPORTANT: doesn't work
              super(B, b) = a
              ####
              return b
  </code></pre>
  
  <p>If this serialization pattern is terrible and you have alternatives, please let me know. However, at the current stage I'm not sure how to re-assign the superclass's member variables as <code>a</code>'s attributes(since <code>a</code>'s state might be different than during initial construction). I know I could do something like <code>super(B,b).__dict__ = a.__dict__</code>, but it just doesn't feel right. <em>What is the python-idiomatic way to perform something like this?</em></p>