79214899

Date: 2024-11-22 11:59:16
Score: 1
Natty:
Report link

I know this dos not directly respond to the question, but one solution might be to turn the problem the other way around:

How do i iterate over a potentially consumable iterable more than one time:

from itertools import tee
from types import Iterable


def func(thing: Iterable[str]) -> None:
    reps=10
    iterables = tee(thing, reps)
    for i in range(reps):
        for x in iterables[i]:
            do_thing(x)
Reasons:
  • Blacklisted phrase (1): How do i
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Yohann