AIM-PIbd-32-Kurbanova-A-A/aimenv/Lib/site-packages/fontTools/misc/iterTools.py
2024-10-02 22:15:59 +04:00

13 lines
390 B
Python

from itertools import *
# Python 3.12:
if "batched" not in globals():
# https://docs.python.org/3/library/itertools.html#itertools.batched
def batched(iterable, n):
# batched('ABCDEFG', 3) --> ABC DEF G
if n < 1:
raise ValueError("n must be at least one")
it = iter(iterable)
while batch := tuple(islice(it, n)):
yield batch