I would like to have infinite iterator/generator with each turn return constant width sliced wrapped-around string. Dead simple code....
s = '123456789 '
it = my_iter(s, 9)
print(next(it))
print(next(it))
print(next(it))
print(next(it))
print(next(it))
will return:
123456789
23456789
3456789 1
456789 12
I believe cycle form intercools can be helpful, but I can combine wrapping-around and slicing of cycle. Here is not wrapping version:
def my_iter(s, d):
i = 0
while True:
yield s[i:d+i]
i = i + 1