dictutils.ops.map_itemsΒΆ
- dictutils.ops.map_items(d, fn, *, deep=False)[source]ΒΆ
Transform both keys and values in a mapping using a function.
- Parameters:
- Return type:
- Returns:
New mapping with transformed items
Example
>>> import json >>> data = {"count": 5, "total": 100} >>> result = map_items(data, lambda k, v: (f"{k}_value", v * 10)) >>> print(json.dumps(result, indent=4)) { "count_value": 50, "total_value": 1000 }