title: python subclass access to class variable of parent
body: <p>I was surprised to to learn that a class variable of a subclass can't access a class variable of the parent without specifically indicating the class name of the parent:</p>
  
  <pre><code>&gt;&gt;&gt; class A(object):
  ...     x = 0
  ... 
  &gt;&gt;&gt; class B(A):
  ...     y = x+1
  ... 
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "&lt;stdin&gt;", line 2, in B
  NameError: name 'x' is not defined
  &gt;&gt;&gt; class B(A):
  ...     y = A.x + 1
  ... 
  &gt;&gt;&gt; B.x
  0
  &gt;&gt;&gt; B.y
  1
  </code></pre>
  
  <p>Why is it that in defining B.y I have to refer to A.x and not just x?  This is counter to my intuition from instance variables, and since I can refer to B.x after B is defined.</p>