title: Python class variable name vs __name__
body: <p>I'm trying to understand the relationship between the variable a Python class object is assigned to and the <code>__name__</code> attribute for that class object. For example:</p>
  
  <pre><code>In [1]: class Foo(object):
     ...:     pass
     ...: 
  
  In [2]: Foo.__name__ = 'Bar'
  
  In [3]: Foo.__name__
  Out[3]: 'Bar'
  
  In [4]: Foo
  Out[4]: __main__.Bar
  
  In [5]: Bar
  ---------------------------------------------------------------------------
  NameError                                 Traceback (most recent call last)
  &lt;ipython-input-5-962d3beb4fd6&gt; in &lt;module&gt;()
  ----&gt; 1 Bar
  
  NameError: name 'Bar' is not defined
  </code></pre>
  
  <p>So it seems like I have changed the <code>__name__</code> attribute of the class but I can't refer to it by that name. I know this is a bit general but could someone explain the relationship between <code>Foo</code> and <code>Foo.__name__</code>?</p>