Tutorial

Install

pip install pymlconf

Usage

The entry point of the library is the Root class. But a proxy: DeferredRoot is also provided to let users import root object before initialization.

from pymlconf import DeferredRoot

settings = DeferredRoot()

Import settings everywhere in your application’s source code.

Then you may initialize the settings object when your data is ready:

context = {
    'here': 'path/to/here'
}

builtins = '''
  a: %(here)s
 '''

settings.initialzie(builtins, context)
print(settings.a)

Loading YAML files

You can load and merge your configuration file(s) using Root.load_file().

settings.loadfile(filename)