Meaning of self.__dict__ = self in a class definition
<p>I'm trying to understand the following snippet of code:</p>

<pre><code>class Config(dict):
    def __init__(self):
        self.__dict__ = self
</code></pre>

<p>What is the purpose of the line <code>self.__dict__ = self</code>? I suppose it overrides the default <code>__dict__</code> function with something that simply returns the object itself, but since <code>Config</code> inherits from <code>dict</code> I haven't been able to find any difference with the default behavior.</p>

<p>As per <a href="https://docs.python.org/2/library/stdtypes.html#object.__dict__" rel="nofollow">Python Document</a>, <code>object.__dict__</code> is:</p>

<blockquote>
  <p>A dictionary or other mapping object used to store an objectâs (writable) attributes.</p>
</blockquote>

<p>Below is the sample example:</p>

<pre><code>&gt;&gt;&gt; class TestClass(object):
...     def __init__(self):
...         self.a = 5
...         self.b = 'xyz'
... 
&gt;&gt;&gt; test = TestClass()
&gt;&gt;&gt; test.__dict__
{'a': 5, 'b': 'xyz'}
</code></pre>

python