get_nested

This commit is contained in:
John Lancaster
2026-02-21 23:19:23 -06:00
parent 842868c491
commit 941e689c19

View File

@@ -44,3 +44,12 @@ class HookedContainer(ABC, Sized, Iterable[T], Container[T]):
@abstractmethod
def insert(self, index, value): ...
# Custom Methods
def get_nested(self, keys):
"""Recursively call __getitem__ with each key in the iterable."""
result = self
for key in keys:
result = result[key]
return result