]> granicus.if.org Git - python/commitdiff
Update itertools recipes to use next().
authorRaymond Hettinger <python@rcn.com>
Mon, 23 Feb 2009 19:38:09 +0000 (19:38 +0000)
committerRaymond Hettinger <python@rcn.com>
Mon, 23 Feb 2009 19:38:09 +0000 (19:38 +0000)
Doc/library/itertools.rst

index 32ad792fb27257d2eaba98808166778e181d40df..6e6b6d99b28b185f4d040eebdfbd5901e5066794 100644 (file)
@@ -326,14 +326,14 @@ loops that truncate the stream.
               return self
           def __next__(self):
               while self.currkey == self.tgtkey:
-                  self.currvalue = next(self.it) # Exit on StopIteration
+                  self.currvalue = next(self.it)    # Exit on StopIteration
                   self.currkey = self.keyfunc(self.currvalue)
               self.tgtkey = self.currkey
               return (self.currkey, self._grouper(self.tgtkey))
           def _grouper(self, tgtkey):
               while self.currkey == tgtkey:
                   yield self.currvalue
-                  self.currvalue = next(self.it) # Exit on StopIteration
+                  self.currvalue = next(self.it)    # Exit on StopIteration
                   self.currkey = self.keyfunc(self.currvalue)
 
 
@@ -652,8 +652,7 @@ which incur interpreter overhead.
    def pairwise(iterable):
        "s -> (s0,s1), (s1,s2), (s2, s3), ..."
        a, b = tee(iterable)
-       for elem in b:
-           break
+       next(b, None)
        return zip(a, b)
 
    def grouper(n, iterable, fillvalue=None):