def get_value_by_keypath(obj, keypath, **kwargs):

    if len(keypath) == 0:
        raise KeyError(keypath)

    has_default = 'default' in kwargs
    default = kwargs.get('default')

    target = obj
    for keypath_component in map(_keypath_component_handler, keypath.split('.')):
        if isinstance(target, Sequence) and isinstance(keypath_component, int):
            if keypath_component < len(target) or not has_default:
                target = target[keypath_component]
            else:
                return default
        elif isinstance(target, dict):
            if has_default:
                target = target.get(keypath_component, default)
            else:
                target = target[keypath_component]
        elif has_default:
            return default
        else:
            raise KeyError(keypath)
    return target
Set class attributes from config dictionary.
dataset/ETHPy150Open sodastsai/taskr/taskr/contrib/collections.py/get_value_by_keypath--crossover with--dataset/ETHPy150Open box/ClusterRunner/app/master/job_config.py/JobConfig._unpack