Python Constants
<p>I have done searches on Google and here at Stackoverflow but can not find what I am looking for.</p>

<p>I am relatively new to Python. I looking to create a "settings" module where various application specific constants will be stored.</p>

<p>Here is how I am wanting to setup my code</p>

<p>settings.py</p>

<pre><code>CONSTANT = 'value'
</code></pre>

<p>script.py</p>

<pre><code>import settings

def func():
    var = CONSTANT
    --- do some more coding ---
    return var
</code></pre>

<p>I am getting a Python error stating: "global name 'CONSTANT' is not defined.</p>

<p>I have noticed on Django's source code their settings.py file has constants named just like I do. I am confused on how they can be imported to a script and referenced through the application.</p>

<p><strong>EDIT</strong></p>

<p>Thank you for all your answers! I tried the following:</p>

<pre><code>import settings

print settings.CONSTANT
</code></pre>

<p>I get the same error: <em>ImportError: cannot import name CONSTANT</em></p>
