title: Add to parentclass's class attribute in subclass
body: <p>I may be on the wrong path here, so if my approach to this is bogus, please advice.</p>
  
  <p>Basically I have a class that has a dictionary containing printing information for every property. I create a child of this class that adds another property:</p>
  
  <pre><code>class A(object):
  
      _print_dict = {"a": "ms"}
  
      def __init__(self):
          self.a = 5
  
      def __str__(self):
          s = ""
          for attr in self._print_dict:
              s += "{} {}\n".format(getattr(self, attr), _print_dict[attr])
          return s
  
  class B(A):
  
      def __init__(self):
          super(B, self).__init__()
          self.b = 10
  </code></pre>
  
  <p>I could update in <code>B.__init__</code>, but that would make <code>_print_dict</code>a instance attribute, right?</p>
  
  <pre><code>class B(A):
  
      def __init__(self):
          super(B, self).__init__()
          self.b = 10
          self._print_dict.update({"b": "V"})
  </code></pre>
  
  <p>When trying to access <code>_print_dict</code> outside <code>__init__</code> however, i get a <code>NameError</code>:</p>
  
  <pre><code>class B(A):
  
      _print_dict.update({"b": "V"})
  
      def __init__(self):
          super(B, self).__init__()
          self.b = 10
  </code></pre>
  
  <p>The same obviously happens with <code>self._print_dict</code>, since <code>self</code> is not defined when the class is created (I presume).</p>
  
  <p>Is there a way to alter the class attribute <code>_print_dict</code> in the subclass <code>B</code>? Without altering it for class <code>A</code> as well?</p>
  
  <h2>Edit:</h2>
  
  <p>I obviously missed using the parent class's name explicitly:</p>
  
  <pre><code>class B(A):
  
      _print_dict = A._print_dict.copy()
      _print_dict.update({"b": "V"})
  
      def __init__(self):
          super(B, self).__init__()
          self.b = 10
  </code></pre>
  
  <p>Is this the way to do it? At least it seems to work...</p>