Instead, I use dictionaries:
config = dict( api_url = 'http://example.com/api', timeout = 1.5, debug = True) countries = dict( new_zealand = 1, united_states = 2)
If you find attribute access cumbersome in a Python dict , try attrdict :
class attrdict(dict): def __init__(self, *args, **kwargs): dict.__init__(self, *args, **kwargs) self.__dict__ = self
It allows you to access dictionary entries with keys that are valid identifiers as attributes, for example. config.api_url instead of config["api_url"] .
Of course, I use lowercase names for them.
Sven marnach
source share