From: Raymond Hettinger Date: Mon, 23 Feb 2009 19:44:00 +0000 (+0000) Subject: Update itertools recipes to use next(). X-Git-Tag: 3.0~368 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=72e002441b1416e114fbc460785b33280f765d98;p=thirdparty%2FPython%2Fcpython.git Update itertools recipes to use next(). --- diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 2c537ceaf346..c523d15a6991 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -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):