In class definition inherited from dict why is there a difference in defining attributes?
<p>In a class inherited from dict, why don't the two ways of defining an attribute produce the same result? Why do I see attr1 but not attr2?</p>

<pre><code>class my_dict(dict):
   def __init__(self):
       dict.__init__(self)
       self['attr1'] = 'seen'
       setattr(self, 'attr2', 'unseen')

In [1]: x = my_dict()

In [2]: x
Out[2]: {'attr1': 'seen'}
</code></pre>
