diff hglib/util.py @ 0:79f88b4db15f

Initial commit
author Idan Kamara <idankk86@gmail.com>
date Wed, 20 Jul 2011 16:09:34 -0500
parents
children d7903b923217
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hglib/util.py	Wed Jul 20 16:09:34 2011 -0500
@@ -0,0 +1,6 @@
+import itertools
+
+def grouper(n, iterable):
+    ''' list(grouper(2, range(4))) -> [(0, 1), (2, 3)] '''
+    args = [iter(iterable)] * n
+    return itertools.izip(*args)