title: Python subclass counter
body: <p>I have this python code. The result is <code>TopTest: attr1=0, attr2=1</code> for X which is fine but the result is <code>SubTest: attr1=2, attr2=3</code> for Y which I don't quite understand. </p>
  
  <p>Basically, I have a class attribute, which is a counter, and it runs in the <code>__init__ method</code>. When I launch Y, the counter is set to 2 and only after are the attributes are assigned. I don't understand why it starts at 2. Shouldn't the subclass copy the superclass and the counter restart at 0?</p>
  
  <pre><code>class AttrDisplay: 
    def gatherAttrs(self):        
      attrs = []        
      for key in sorted(self.__dict__):            
          attrs.append('%s=%s' % (key, getattr(self, key)))        
      return ', '.join(attrs)
    def __repr__(self):        
      return '[%s: %s]' % (self.__class__.__name__, self.gatherAttrs())
  
  class TopTest(AttrDisplay): 
      count = 0        
      def __init__(self):            
          self.attr1 = TopTest.count            
          self.attr2 = TopTest.count+1            
          TopTest.count += 2
  
  class SubTest(TopTest):
      pass
  
  X, Y = TopTest(), SubTest()         
  print(X)                            
  print(Y)                         
  </code></pre>