title: Alternative to Passing Global Variables Around to Classes and Functions
body: <p>I'm new to python, and I've been reading that using <code>global</code> to pass variables to other functions is considered noobie, as well as a bad practice. I would like to move away from using global variables, but I'm not sure what to do instead.</p>
  
  <p>Right now I have a UI I've created in wxPython as its own separate class, and I have another class that loads settings from a .ini file. Since the settings in the UI should match those in the .ini, how do I pass around those values? I could using something like: <code>Settings = Settings()</code> and then define the variables as something like <code>self.settings1</code>, but then I would have to make <code>Settings</code> a global variable to pass it to my UI class (which it wouldn't be if I assign in it <code>main()</code>). </p>
  
  <p>So what is the correct and pythonic way to pass around these variables?</p>
  
  <p><strong>Edit:</strong> Here is the code that I'm working with, and I'm trying to get it to work like Alex Martelli's example. The following code is saved in <code>Settings.py</code>:</p>
  
  <pre><code>import ConfigParser
  
  class _Settings():
      @property
      def enableautodownload(self): return self._enableautodownload
      def __init__(self):
          self.config = ConfigParser.ConfigParser()
  
          self.config.readfp(open('settings.ini'))
          self._enableautodownload=self.config.getboolean('DLSettings', 'enableautodownload')
  
  settings = _Settings()
  </code></pre>
  
  <p>Whenever I try to refer to <code>Settings.settings.enableautodownload</code> from another file I get: <code>AttributeError: 'module' object has no attribute 'settings'</code>. What am I doing wrong?</p>
  
  <p><strong>Edit 2:</strong> Never mind about the issue, I retyped the code and it works now, so it must have been a simple spelling or syntax error.</p>