libb.Setting

class Setting(*args, **kwargs)[source]

Bases: dict

Dict where d['foo'] can also be accessed as d.foo.

Automatically creates new sub-attributes of type Setting. This behavior can be locked to turn off later.

Warning

Not copy safe.

Basic Usage:

>>> cfg = Setting()
>>> cfg.unlock() # locked after config.py load
>>> cfg.foo.bar = 1
>>> hasattr(cfg.foo, 'bar')
True
>>> cfg.foo.bar
1

Locking Behavior:

>>> cfg.lock()
>>> cfg.foo.bar = 2
Traceback (most recent call last):
 ...
ValueError: This Setting object is locked from editing
>>> cfg.foo.baz = 3
Traceback (most recent call last):
 ...
ValueError: This Setting object is locked from editing

Unlocking:

>>> cfg.unlock()
>>> cfg.foo.baz = 3
>>> cfg.foo.baz
3
__getattr__(name)[source]

Create sub-setting fields on the fly

static lock()[source]
static unlock()[source]