Skip to content

Instantly share code, notes, and snippets.

@gidgid
gidgid / partition_example.py
Last active April 19, 2023 11:18
shows how to use the more_itertools partition function
from typing import Dict, Iterable, Set, Tuple
from more_itertools import partition
def process(
names: Iterable[str], whitelisted_names: Set[str], name_to_email: Dict[str, str]
) -> Tuple[Iterable[str], Iterable[str]]:
refused_names, approved_names = partition(
lambda name: name in whitelisted_names, names