title: Overriding Global Variables Used in Class Definition When Creating Subclass
body: <p>My apologies if this question has already been answered, I tried searching but couldn't find anything.</p>
  <p>I've downloaded a package off the internet and it has a class, say <code>Bicycle</code> that I want to create a subclass of. <code>Bicycle</code> uses global variables declared locally in <code>bicycle.py</code>, as below:</p>
  <pre><code>COLOR_DICT = { &quot;blue&quot; : 0, &quot;green&quot; : 1, &quot;red&quot; : 2}
  
  class Bicycle:
  
      ...    
  
      def encode(self):
          return (self.name, self.height, COLOR_DICT[self.color])
  </code></pre>
  <p>I want to subclass bicycle, say with a Tricycle class, and I want to retain much of the functionality (and most of the global variables) defined in <code>bicycle.py</code>, but I want to use a different <code>COLOR_DICT</code>. If I wanted <code>encode</code> to use my different <code>COLOR_DICT</code> would I have to override encode locally in my tricycle file, even though the code will be exactly the same? If I just redefine <code>COLOR_DICT</code> in the new file I assume the superclass still references the one defined in its file.</p>