title: Access base class attribute in derived class - in "class scope"
body: <pre><code>class Outer(object):
      class InnerBase(object): _var = {'foo', 'bar'}
      class Derived(InnerBase):
          _var = _var | {'baz'} # NameError: name '_var' is not defined
          _var = InnerBase._var | {'baz'} #  name 'InnerBase' is not defined
          _var = Outer.InnerBase._var | {'baz'} #  free variable 'Outer'
          # referenced before assignment in enclosing scope
  </code></pre>
  
  <p>Moving _var in <code>Outer</code> does not help - moving it in module scope would work but defeats the purpose of having classes. So how to go about that ?</p>
  
  <p>EDIT: coming from Java so the scoping rules of classes are a head scratcher for me - a briefing would be appreciated. This works btw:</p>
  
  <pre><code>    class Derived(InnerBase): pass
      Derived._var = InnerBase._var | {'baz'}
  </code></pre>
  
  <p>but it's not the pinnacle of elegance.</p>
  
  <p>Related: <a href="https://stackoverflow.com/questions/1765677/python-nested-classes-scope">Nested classes&#39; scope?</a> - but here we specifically want to access our parent class (rather than the Outer type)</p>
  
  <p>EDIT2: What I am actually after is a <code>_var = __class__._var</code>-like syntax (or hack), or an explanation as to <em>why</em> it's not there</p>