(config, property_path, value)
return config_copy
Set key at property_path to value in config & return new config.

    config is not mutated.

    property_path is a series of dot separated values. Any part of the path
    that does not exist is created.
Set key at property_path to value in config & return new config.
Set key at property_path to value in config & return new config .
def set_item_in_config(config, property_path, value):
    """
    Set key at property_path to value in config & return new config.

    config is not mutated.

    property_path is a series of dot separated values. Any part of the path
    that does not exist is created.
    """
    path_components = property_path.split(".")

    # Mutate a copy of the config, not config itself
    cur_part = config_copy = deepcopy(config)
    for i, cur_path in enumerate(path_components):
        cur_path = path_components[i]
        if i == len(path_components) - 1:
            # Final component
            cur_part[cur_path] = value
        else:
            # If we are asked to create new non-leaf nodes, we will always make them dicts
            # This means setting is *destructive* - will replace whatever is down there!
            if cur_path not in cur_part or not _is_dict(cur_part[cur_path]):
                cur_part[cur_path] = {}
            cur_part = cur_part[cur_path]

    return config_copy
def set_item_in_config ( config , property_path , value ) : path_components = property_path . split ( "." ) # Mutate a copy of the config, not config itself cur_part = config_copy = deepcopy ( config ) for i , cur_path in enumerate ( path_components ) : cur_path = path_components [ i ] if i == len ( path_components ) - 1 : # Final component cur_part [ cur_path ] = value else : # If we are asked to create new non-leaf nodes, we will always make them dicts # This means setting is *destructive* - will replace whatever is down there! if cur_path not in cur_part or not _is_dict ( cur_part [ cur_path ] ) : cur_part [ cur_path ] = { } cur_part = cur_part [ cur_path ] return config_copy