from itertools import izip islice def rgp source for in izip islice so

1
2
3
4
5
from itertools import izip, islice
def rgp(source, n):
for i in izip(islice(source, None, None, n), islice(source, n-1, None, n)):
yield i