summaryrefslogtreecommitdiffstats
path: root/Doc/library/itertools.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-02-23 19:38:09 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-02-23 19:38:09 (GMT)
commit21315ba9c819fe0de35b9b73fdef502cf186fd14 (patch)
treef1557cc0d310ab4566f3a7d8f53617f496784acd /Doc/library/itertools.rst
parent6d327b0d53707ebc05d246a7f5173f37583f1672 (diff)
downloadcpython-21315ba9c819fe0de35b9b73fdef502cf186fd14.zip
cpython-21315ba9c819fe0de35b9b73fdef502cf186fd14.tar.gz
cpython-21315ba9c819fe0de35b9b73fdef502cf186fd14.tar.bz2
Update itertools recipes to use next().
Diffstat (limited to 'Doc/library/itertools.rst')
-rw-r--r--Doc/library/itertools.rst7
1 files changed, 3 insertions, 4 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index 32ad792..6e6b6d9 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -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):