Why is my instance variable not in __dict__?
<p>If I create a class <code>A</code> as follows:</p>

<pre><code>class A:
    def __init__(self):
        self.name = 'A'
</code></pre>

<p>Inspecting the <code>__dict__</code> member looks like <code>{'name': 'A'}</code></p>

<p>If however I create a class <code>B</code>:</p>

<pre><code>class B:
    name = 'B'
</code></pre>

<p><code>__dict__</code> is empty.</p>

<p>What is the difference between the two, and why doesn't <code>name</code> show up in <code>B</code>'s <code>__dict__</code>?</p>

<p><code>B.name</code> is a class attribute, not an instance attribute.  It shows up in <code>B.__dict__</code>, but not in <code>b = B(); b.__dict__</code>.</p>

<p>The distinction is obscured somewhat because when you access an attribute on an instance, the class dict is a fallback.  So in the above example, <code>b.name</code> will give you the value of <code>B.name</code>.</p>
