title: how to make classes with __getattr__ pickable
body: <p>How can I modify the classes below to make them pickeable? </p>
  
  <p>This question: <a href="https://stackoverflow.com/questions/42272335/how-to-make-a-class-which-has-getattr-properly-pickable">How to make a class which has __getattr__ properly pickable?</a> is similar but refer to wrong exception in the use of <strong>getattr</strong>.</p>
  
  <p>This other question seems to provide meaningful insight <a href="https://stackoverflow.com/questions/12101574/why-does-pickle-dumps-call-getattr">Why does pickle.dumps call __getattr__?</a>, however it fails to provide an example, and I honestly cannot understand what I am suppose to implement. </p>
  
  <pre><code>import pickle
  class Foo(object):
      def __init__(self, dct):
          for key in dct:
              setattr(self, key, dct[key])
  
  
  class Bar(object):
      def __init__(self, dct):
          for key in dct:
              setattr(self, key, dct[key])
  
      def __getattr__(self, attr):
          """If attr is not in channel, look in timing_data
          """
          return getattr(self.foo, attr)
  
  if __name__=='__main__':
      dct={'a':1,'b':2,'c':3}
      foo=Foo(dct)
      dct2={'d':1,'e':2,'f':3,'foo':foo}
      bar=Bar(dct2)
      pickle.dump(bar,open('test.pkl','w'))
      bar=pickle.load(open('test.pkl','r'))
  </code></pre>
  
  <p>Results:</p>
  
  <pre><code>     14         """If attr is not in channel, look in timing_data
       15         """
  ---&gt; 16         return getattr(self.foo, attr)
       17
       18 if __name__=='__main__':
  
  RuntimeError: maximum recursion depth exceeded while calling a Python object
  </code></pre>