Update itertools recipes to use next().

This commit is contained in:
Raymond Hettinger 2009-02-23 19:38:09 +00:00
parent 6d327b0d53
commit 21315ba9c8
1 changed files with 3 additions and 4 deletions

View File

@ -652,8 +652,7 @@ which incur interpreter overhead.
def pairwise(iterable): def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..." "s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable) a, b = tee(iterable)
for elem in b: next(b, None)
break
return zip(a, b) return zip(a, b)
def grouper(n, iterable, fillvalue=None): def grouper(n, iterable, fillvalue=None):