]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Update itertools recipes to use next().
authorRaymond Hettinger <python@rcn.com>
Mon, 23 Feb 2009 19:44:00 +0000 (19:44 +0000)
committerRaymond Hettinger <python@rcn.com>
Mon, 23 Feb 2009 19:44:00 +0000 (19:44 +0000)
Doc/library/itertools.rst

index 2c537ceaf34693a208a662e16608bea49c9892ef..c523d15a6991efca2a5665f98c43f116c918c81c 100644 (file)
@@ -240,14 +240,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)
 
 
@@ -566,8 +566,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):