reddit-image-wall-getter/reddit_imgs/system/flattener.py

14 lines
317 B
Python

#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
from typing import Collection, Generator, TypeVar
T = TypeVar('T')
def flatten_generator(list_of_lists: Collection[Collection[T]]) -> Generator[T, None, None]:
yield from []
for sublist in list_of_lists:
for item in sublist:
yield item