title: How can this global class variable be pep8 compliant and still work?
body: <p><a href="http://www.python.org/dev/peps/pep-0008/#function-and-method-arguments" rel="nofollow">Pep8</a> advises to always use <code>cls</code> as the first argument of a class method definition.
  Now suppose I want to use a class variable(in this case: <code>cls.cartridge_state</code>) that can also be used in an instance method (in this case: <code>__init__</code>). So for that I need to make the variable global(see code below). But instantiating <code>FountainPen</code> generates the following runtime error:</p>
  
  <pre><code>self.cartridge_state = cls.cartridge_state
  NameError: global name 'cls' is not defined
  </code></pre>
  
  <p>But then again when I change <code>global cartridge_state</code> into <code>global cls.cartridge_state</code> I get a syntaxError when i try to import the module.</p>
  
  <pre><code>class FountainPen(object):
      cartridge_ink = "water-based"
      @classmethod
      def toggle_default_cartridge_state(cls):
          i = 0
          cartridge_states = ['non-empty','empty']
          global cartridge_state
          cls.cartridge_state = cartridge_states[i]
          i += 1
  
      def __init__(self):
          self.cartridge_state = cls.cartridge_state
          global number_of_refills
          self.number_of_refills = 0
  
      def write(self):
          print Pen.write(self)
          self.cartridge_state = "empty"
          return self.cartridge_state
  
      def refill(self):
          self.cartridge_state = "non-empty"
          self.number_of_refills += 1
  </code></pre>
  
  <p>How can I let the class variable <code>cartridge_state</code> be pep8 compliant and make this code work without errors?</p>