Skip to content

treeo.make_mutable

Returns a context manager that makes a tree mutable.

Parameters:

Name Type Description Default
tree Tree

The tree to make mutable.

required
toplevel_only bool

If True, only the top-level tree is made mutable.

False
Source code in treeo/tree.py
def make_mutable(tree: Tree, toplevel_only: bool = False):
    """
    Returns a context manager that makes a tree mutable.

    Arguments:
        tree: The tree to make mutable.
        toplevel_only: If `True`, only the top-level tree is made mutable.
    """
    if toplevel_only:
        return _make_mutable_toplevel(tree)
    else:
        return _make_mutable(tree)