Python: why is __dict__ attribute not in built-in class instances
<p>If my understanding of the Python data model is correct, both classes and class instances have associated <code>__dict__</code> objects which contain all the attributes.  However, I'm a little confused as to why certain class instances, such as instances of <code>str</code> for example, don't have a <code>__dict__</code> attribute.</p>

<p>If I create a custom class:</p>

<pre><code>class Foo:
     def __init__(self):
             self.firstname = "John"
             self.lastname = "Smith"
</code></pre>

<p>Then I can get the instance variables by saying:</p>

<pre><code>&gt;&gt;&gt; f = Foo()
&gt;&gt;&gt; print(f.__dict__)
{'lastname': 'Smith', 'firstname': 'John'}
</code></pre>

<p>But if I try to do the same with an instance of the built-in <code>str</code>, I get:</p>

<pre><code>&gt;&gt;&gt; s = "abc"
&gt;&gt;&gt; print(s.__dict__)
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
AttributeError: 'str' object has no attribute '__dict__'
</code></pre>

<p>So, why don't instances of <code>str</code> have a <code>__dict__</code> attribute?</p>
