What's the best practice using a settings file in Python?

The Solution to What's the best practice using a settings file in Python? is


You can have a regular Python module, say config.py, like this:

truck = dict(
    color = 'blue',
    brand = 'ford',
)
city = 'new york'
cabriolet = dict(
    color = 'black',
    engine = dict(
        cylinders = 8,
        placement = 'mid',
    ),
    doors = 2,
)

and use it like this:

import config
print(config.truck['color'])  

~ Answered on 2011-02-20 11:49:11


Most Viewed Questions: