title: Access class static variable from super class in python
body: <p>I am creating a couple of 'Child' classes which are quite similar and thus wanted to group common methods in a parent class. My problem comes when trying to access static variables of the child classes from the super class.</p>
  
  <p>The following code throws the error:  <code>NameError: name 'var' is not defined</code></p>
  
  <pre><code>class Parent:
      @staticmethod
      def do_something_with_var():
          print(var)
  
  class Child(Parent):
      var = "Hello world"
  
  Child.do_something_with_var()
  </code></pre>
  
  <p>Next thing I tried was obviously to declare <code>var</code> in <code>Parent</code>, but the same error persists.</p>
  
  <pre><code>class Parent:
      var = ""
  
      @staticmethod
      def do_something_with_var():
          print(var)
  
  class Child(Parent):
      var = "Hello world"
  
  Child.do_something_with_var()
  </code></pre>
  
  <p>A solution that I found was to receive the sender class, but then the call becomes a bit ugly:</p>
  
  <pre><code>class Parent:
      @staticmethod
      def do_something_with_var(cls):
          print(cls.var)
  
  class Child(Parent):
      var = "Hello world"
  
  Child.do_something_with_var(Child)
  </code></pre>