eotransform.transformers.apply_to_enumeration.ApplyToEnumeration

class ApplyToEnumeration(transforms: Dict[int, Transformer[Iterable[InSelectT], Iterator[OutSelectT]]])[source]

Bases: Transformer[Iterable[InSelectT], Iterator[OutSelectT]]

Apply a transformations to the element of an enumeration selected by the index >>> class Plus(Transformer[int, int]): … def __init__(self, value): … self.value = value … … def __call__(self, x): … return x + self.value … >>> list(ApplyToEnumeration({1: Plus(1), 2: Plus(2)})([0, 1, 2])) [0, 2, 4]

Parameters:

transforms – Dictionary of transformations applied to the index specified as key

Methods