title: Python parent class accessing class variable of child class
body: <p>I'm currently trying to implement some inheritance in my Python project and have hit a road block. I'm trying to create a baseParentClass that will handle the basic functionality for a lot of child classes. In this specific example I am trying to initialize an instance with a number of attributes (set to 0), stored as a class variable list (called ATTRS) in the Child. I am unsure of how to use this ATTRS in the parent class. </p>
  
  <pre><code>class Parent(object):
      def __init__():
          for attr in ATTRS:
              setattr(self, attr, 0)
  
  class Child(Parent):
      #class variable
      ATTRS = [attr1, attr2, attr3]
  
      def __init__():
          super(Child, self).__init__()
  </code></pre>
  
  <p>I could store ATTRS as self.ATTRS in Child, and then use self.ATTRS in Parent successfully, but it seems preferable to me to have them stored as a class variable.</p>
  
  <p>Alternatively I could pass ATTRS as a parameter like so:</p>
  
  <pre><code>class Child(Parent):
      #class variable
      ATTRS = [attr1, attr2, attr3]
  
      def __init__():
          super(Child, self).__init__(ATTRS)
  </code></pre>
  
  <p>but I'm wondering whether this somehow defeats the point of using inheritance in the first place?</p>
  
  <p>I'd be grateful for any ideas, hints or feedback whether I'm barking up the wrong tree completely!</p>
  
  <p>Thanks</p>