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

14 lines
317 B
Python
Raw Normal View History

2020-07-20 01:54:26 +00:00
#!/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