summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--itertoolset.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/itertoolset.py b/itertoolset.py
index a20d03b..314ba0b 100644
--- a/itertoolset.py
+++ b/itertoolset.py
@@ -1,6 +1,11 @@
from itertools import *
import collections
+def grouper(n, iterable, fillvalue=None):
+ "grouper(3, 'ABCDEFG', 'x') --> ABC DEF Gxx"
+ args = [iter(iterable)] * n
+ return izip_longest(fillvalue=fillvalue, *args)
+
def roundrobin(*iterables):
"""roundrobin('ABC', 'D', 'EF') --> A D E B F C"""
pending = len(iterables)