title: Having trouble understanding some class code in python
body: <p>I'm pretty new to programming and am having some trouble understanding the output of this code.</p>
  
  <pre><code>#testclass.py
  
  class TestCount:
      count = 0
      def __init__(self):
          self.attr1 = TestCount.count
          self.attr2 = TestCount.count + 1
          TestCount.count += 2
  
  x = TestCount()
  y = TestCount()
  
  print(x.attr1, x.attr2)
  print(y.attr1, y.attr2)
  </code></pre>
  
  <p>This is a rework of a larger example out of a book I'm currently learning out of.  When this code is ran it gives:</p>
  
  <pre><code>0 1
  2 3
  </code></pre>
  
  <p>When I expect it to be:</p>
  
  <pre><code>0 1
  0 1
  </code></pre>
  
  <p>What is the fundamental that I'm missing here?  I see y as a new instance but it seems to be picking up where x left off.  Sorry if I'm not explaining myself clearly but I'm new at this.</p>