Python: What is the recommended way to set configuration settings for a module when you import it?
<p>I've seen people use monkey-patching to set options on a module, for example:</p>

<blockquote>
  <blockquote>
    <blockquote>
      <p>import mymodule<br>
      mymodule.default_img = "/my/file.png"<br>
      mymodule.view_default_img()  </p>
    </blockquote>
  </blockquote>
</blockquote>

<p>And Django, for example, has settings.py for the entire Django app, and it always grates on me a little.</p>

<p>What are the other ways to manage configuration settings on a module? What's recommended? It seems like there's often no nice way to setup module-level configuration.</p>

<p>Obviously, completely avoiding configuration is by far the most preferable, and it's usually better to use classes, or pass in the argument to a function. But sometimes you can't avoid having settings of some sort, and sometimes it really does make sense to have global module-wide settings just for convenience (for example, Django's template system -- having to specify the base path for every template would be a nightmare, definitely not good DRY code).</p>
