title: How to declare multiple global variables in python?
body: <p>Suppose I have a <code>class A</code> that has a <code>contains_variable</code> method that contains multiple variables. What I want to achieve here is declaring all these variables <code>global</code> so that they could be used outside their current local scope.</p>
  
  <p>What I don't want is to make these variables class variables or define them outside this <code>contains_variable</code> method since it contains <code>self.foo</code> and other such variables that are used in other classes and files and defining them outside the method would mean changing them everywhere else as well which would be cumbersome.</p>
  
  <pre class="lang-py prettyprint-override"><code>class A:
  
      def contains_variables(self, foo):
          self.foo = None
          var1 = 1
          var2 = 2
          var3 = 3
        # upto let's say var 28
          var 28 = 28
  
      def add(self):
          print('var1 + var28 = ', var1 + var28)
  </code></pre>
  
  <p>I realized defining other class for these variables must be a good option but then again it would mean to change every variable at every place it was used.</p>
  
  <pre class="lang-py prettyprint-override"><code>class globalVariables:
  
        foo = None
        var1 = 1
      # upto var28
        var28 = 28  
  
  class A(globalVariables):
  
        print('var1 + var28 = ', globalVariables.var1 + globalVariables28)
  </code></pre>
  
  <p>Prepending every variable with <code>globalVariables</code>just seems unproductive.</p>