from typing import Any, Mapping, MutableMapping _config: MutableMapping[str, Any] = {} def change(new): _config.clear() _config.update(new) def get(*keys: str, default: Any = None, cursor: Mapping = None): ''' Get configuration value. If multple keys are specified, traverse the configuration to retrieve the value. If no value was found, return None. ''' if not cursor: cursor = _config first = keys[0] rest = keys[1:] value = cursor.get(first) return (get(rest, default=default, cursor=value) if value is not None and rest else value) def reference(): return _config