title: Python static variable resolution
body: <p>I am trying to create a counter of all instances created for a particular class.
  It is clear that my code does not increment <code>self.__class__.counter</code> past 1. What am I doing wrong?</p>
  
  <pre><code> class Feature(object):
      counter = 0
      def __init__(self, line):
          self.id = self.__class__.counter
          self.__class__.counter = self.__class__.counter + 1
      def __repr__(self):
          return "Feature: id=%d name=%s" % (self.id,self.name,)
  </code></pre>
  
  <p><strong>Update:</strong>
  This code actually works as intended. 
  Smart folks left some very detailed explanations how statics are being handled in python. I voted to close my question, but hate if the answers will disappear.    </p>