Tutorial

Install

pip install pymlconf

Usage

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

from pymlconf import DiferredRoot

settings = DiferredRoot()

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.load_file(filename)