title: python getattr and setattr with self.__dict__
body: <p>I have been reading about overriding getattr and setattr and I can't figure out if I need the overriding assignments if I use self.__dict__ = self in the constructor. </p>
  
  <p>Once I make an instance of the class</p>
  
  <pre><code>a = OPT(foo='bar')
  </code></pre>
  
  <p>a.foo and a['foo'] work with and without the __getattr__ and __setattr__ declaration. </p>
  
  <p>Can someone explain if I need both. If I do, why?  Thanks!</p>
  
  <pre><code>class OPT(dict):
      __getattr__ = dict.__getitem__
      __setattr__ = dict.__setitem__
  
      def __init__(self, *args, **kwargs):
          super(OPT, self).__init__(*args, **kwargs)
          self.__dict__ = self
  </code></pre>