PyConfigContainer

PyConfigContainer#

class PyConfigContainer#

Bases: object

Object that can define attributes recursively on the fly.

Allows the config file syntax:

c.group.subgroup.parameter = 3
c.another_group.parameter = True

It patches __getattribute__ to allow this. Any unknown attribute is automatically created and assigned a new instance of PyConfigContainer. The attributes values can be explored (recursively) in the __dict__ attribute.

This is a very minimalist approach and caution should be applied if this class is to be expanded.

as_flat_dict()#

Return flat dict of attributes.

We must use a flat dict, a nested one would not differentiate nested attribute and a dictionnary as attribute value.

Return type:

dict