How to do configuration of a python environment
Question: During the last years I mostly used django. Django uses the environment
variable `DJANGO_SETTINGS_MODULE` to find its configuration.

Now I have a project where I don't use django and I would like to have a clean
and easy to understand way to load the configuration.

Example:

I want a global boolean to turn debugging on or off:

    
    
    settings.DEBUG
    

I guess there are thousands of ways to do it.

But what is the most pythonic way to store and load project settings?

... maybe the Python community already settled on a well known default way I
just don't know yet.


Answer: From: <https://docs.python.org/2/library/constants.html>

Use the global immutable constant

    
    
    __debug__
    

This constant is true if Python was not started with an -O option.

If you mean to set the logging level, use `logging.setLevel(lvl)`:
<https://docs.python.org/2/library/logging.html#logging.Logger.setLevel>

_Update:_

For general global constants I would use a singleton, i.e. a module, to store
the constants you need. I.e. create a module `config.py`

    
    
    DEBUG = False
    OTHER_THING = True
    

From other modules you can

    
    
    import config
    print(config.DEBUG)
    

