process()
Process a list of items and return a summary.
Usage
process(
items,
strict=False,
)Iterates through the items, applies validation and aggregation, and returns a summary dictionary with counts and status information.
Parameters
items: list-
A list of items to process. Each item should be a string or convertible to string.
strict: bool = False-
If True, raise on invalid items instead of skipping them. Defaults to False.
Returns
dict-
A dictionary with the following keys:
"processed"— number of successfully processed items."skipped"— number of skipped items (0 if strict)."status"—"complete"or"partial".
Raises
ValueError-
If
itemsis empty. TypeError-
If an item is not convertible to string and
strictis True.
Note
The processing order follows the input list order. Items are processed sequentially and results are deterministic for the same input.
Example
process([“a”, “b”, “c”]) {‘processed’: 3, ‘skipped’: 0, ‘status’: ‘complete’}
process([“a”, None, “c”], strict=False) {‘processed’: 2, ‘skipped’: 1, ‘status’: ‘partial’}
Warning
Large lists (>10,000 items) may cause significant memory usage. Consider batching for large inputs.
References
Gang of Four, “Design Patterns”, Iterator pattern.