spekk.trees.core.has_path

Contents

spekk.trees.core.has_path#

spekk.trees.core.has_path(tree: Mapping[Any, Mapping[Any, Tree] | Sequence[Tree] | Any] | Sequence[Mapping[Any, Tree] | Sequence[Tree] | Any] | Any, path: tuple) bool[source]#

Return True if the given path exists in the tree.

>>> tree = {"a": {"b": [1, 2, 3]}}
>>> has_path(tree, ("a", "b", 1))
True
>>> has_path(tree, ("a", "c"))
False