title: How to inherit and extend class attributes in Python?
body: <p>I've made a lot of research on the net but I didn't find the correct way to extend &quot;class&quot; attributes dictionary with new values in a subclass. Most of the documentation are extending attributes inside methods.</p>
  <p>I tried <code>dictionary.update()</code> but it doesn't work.</p>
  <p>This is my example:</p>
  <pre class="lang-py prettyprint-override"><code>class Super(object):
      dictionary = {'one':1, 'two':2}
  
      def __init__(self, var):
          self.var = var
  
      def supermethod(self):
          pass
  </code></pre>
  <p>And I extended it to:</p>
  <pre class="lang-py prettyprint-override"><code>class Subclass(Super):
      dictionary.update({&quot;zero&quot;:0})
  
      def __init__(self, var):
          super(Subclass, self).__init__(var)
          self.var = var
  
      def submethod(self):
          pass
  </code></pre>
  <p>If I override dictionary - it works fine. But If I try to extend, it gives me:</p>
  <blockquote>
  <p>AttributeError: 'Subclass' object has no attribute 'dictionary'</p>
  </blockquote>