I have done searches on Google and here at Stackoverflow but can not find what I am looking for.
I am relatively new to Python. I looking to create a "settings" module where various application specific constants will be stored.
Here is how I am wanting to setup my code
settings.py
CONSTANT = 'value'
script.py
import settings
def func():
var = CONSTANT
--- do some more coding ---
return var
I am getting a Python error stating: "global name 'CONSTANT' is not defined.
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.
EDIT
Thank you for all your answers! I tried the following:
import settings
print settings.CONSTANT
I get the same error: ImportError: cannot import name CONSTANT