Why does cls.__name__ not appear in dir()?
<p>Let's say I have a simple class:</p>

<pre><code>class Foobar(object):
    pass
</code></pre>

<p>If I use <code>dir(Foobar)</code>, I'll get the following output:</p>

<pre><code>['__class__', '__delattr__', '__dict__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__']
</code></pre>

<p>Even though it does not appear in the output of <code>dir()</code>, I can access <code>__name__</code>:</p>

<pre><code>Foobar.__name__
</code></pre>

<p>and get <code>Foobar</code>.</p>

<p>Why does Python behave that way?</p>
