zip and zip_longest for dict.
$ pip install dict-zipdict_zip is zip for dict.
The result keeps the first dictionary's insertion order and skips keys
missing from any dictionary.
>>> from dict_zip import dict_zip
>>> dict_zip({'a': 1, 'b': 2}, {'a': 3, 'b': 4})
{'a': (1, 3), 'b': (2, 4)}dict_zip_longest is zip_longest for dict.
It fills with fillvalue (default: None) when argument dict doesn't have match key.
The result keeps keys in the order they are first seen while scanning the
input dictionaries from left to right.
>>> from dict_zip import dict_zip_longest
>>> dict_zip_longest({'a': 1, 'b': 2, 'c': 4}, {'a': 3, 'b': 4})
{'a': (1, 3), 'b': (2, 4), 'c': (4, None)}map_keys, map_values, and map_items are used to map keys, values, and items of dict.
>>> from dict_zip import map_keys
>>> map_keys({'a': 1, 'b': 2}, str.upper)
{'A': 1, 'B': 2}
>>> from dict_zip import map_values
>>> map_values({'a': 1, 'b': 2}, str)
{'a': '1', 'b': '2'}
>>> from dict_zip import map_items
>>> map_items({'a': 1, 'b': 2}, str.upper, str)
{'A': '1', 'B': '2'}map_items accepts the key mapper as the second positional argument. The
keyword-only func= argument is kept as a backward-compatible alias for
key_func.
tuple_keys is used to convert dict keys to tuple.
>>> from dict_zip import tuple_keys
>>> tuple_keys({'a': 1, 'b': 2})
{('a',): 1, ('b',): 2}dict_zip supports for type hints.
This repository uses lefthook to run the same checks as CI locally, so problems surface before they reach CI.
# Install dependencies
uv sync
# Install the Git hooks (once; requires lefthook on your PATH)
lefthook installOnce installed, the hooks run automatically:
- pre-commit:
uv run poe check - pre-push:
uv run poe checkanduv run poe test
You can also run the checks manually:
uv run poe check
uv run poe testCI still runs the full matrix (see .github/workflows/); the hooks only bring that
feedback earlier on your machine.
The 3-Clause BSD License. See also LICENSE file.
