title: how access to inherited class variable in python
body: <p>I am new to python and I try to understand witring small pieces of code, especially about constructor overloading and class variable. I wrote this to test:</p>
  <pre><code>class parent:
      # class variable
      numberOfInstance = 0
      def __init__(self, arg1):
          # an instance variable
          self._instVar1 = arg1
          parent.numberOfInstance += 1
          # self.__class__.numberOfInstance += 1
  
  class child(parent):
      def __init__(self, arg1, arg2):
          # an instance variable for child
          self._instVar2 = arg2
          super().__init__(arg1)
  
  p1 = parent('an arg')
  p2 = parent('an arg')
  p3 = child('an arg','another' )
  print (p2.numberOfInstance)
  print (p3.numberOfInstance)
  print (child.numberOfInstance)
  print (parent.numberOfInstance)
  </code></pre>
  <p>The result is as I expected: 3,3,3,3 but when I comment the line
  <code>parent.numberOfInstance += 1</code> and uncomment the line
  <code>self.__class__.numberOfInstance += 1</code> changing the way to access the
  class variable, the result is :</p>
  <pre><code>2
  3
  3
  2
  
  Process finished with exit code 0
  </code></pre>
  <p>it seems, for me, very strange because the class variable seems to be duplicate and update in &quot;one
  way&quot; mode. I understand that in the second version the class is <em>child</em> but the variable referenced is the parent variable because incrementation works well.</p>