title: Wrapping global variables in a class (python)
body: <p>I'm new to programming, and have recently learned python and the basics of object oriented programming. I'm aware that having lots of global variables is generally a bad idea, and that I can put them all into a class instead. Is this the right way to do it?</p>
  
  <pre><code>class GameState(object):
      def __init__(self):
          self.variable1 = 1
          self.variable2 = 2
          self.list = [3, 4, 5]
  
  g_state = GameState()
  </code></pre>
  
  <p>And, if I wish to access the variables within g_state, what is the best way to go about doing it?</p>
  
  <p>Pass g_state into the functions/classes that need access?
  Implement getters and call those?
  Use g_state.variable1 directly?</p>
  
  <p>Or is there a better way?</p>
  
  <p>EDIT: To be more specific, I'm trying to write a game in python using pygame, and was thinking of putting my gamestate variables into a class so as to not have a bunch of global variables lying around. I'm unsure of how to access those variables with good design so I don't run into trouble later.</p>