roboto.collection_utils
Module Contents
T
defaultlist
Bases: list[T], Generic[T]
Like collections.defaultdict, but for list.
Automatically supplies a default value when you access an index that hasn’t been set or is out of bounds, without raising an IndexError.
Usage
dl = defaultlist[int](factory=lambda: 0)
dl[5] += 1 # Automatically extends list with 0s up to index 5
print(dl) # [0, 0, 0, 0, 0, 1]Parameters
factory Callable[[], T]Attributes
defaultlist.factory
factory #get_by_path()
Access a key path in a mapping. Returns None if any part of the path is not found or traverses through an object that is not a mapping.
Parameters
target collections.key_path collections.Return type
Any