spekk.trees.core.set#
- spekk.trees.core.set(tree: Mapping[Any, Mapping[Any, Tree] | Sequence[Tree] | Any] | Sequence[Mapping[Any, Tree] | Sequence[Tree] | Any] | Any, value: Any, path: tuple)[source]#
Set the value of the subtree at the given path.
>>> tree = {"a": [1, {"b": 2}, 3], "c": 4} >>> set(tree, 42, ("a", 1, "b")) {'a': [1, {'b': 42}, 3], 'c': 4} >>> set(tree, 42, ("new_key",)) {'a': [1, {'b': 2}, 3], 'c': 4, 'new_key': 42}