summaryrefslogtreecommitdiffstats
path: root/Doc/library
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-02-23 19:32:55 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-02-23 19:32:55 (GMT)
commitd47442e3cb9ba6eda8cca49d2f08a192f1f64e9f (patch)
tree18d0c19e8ae723f3e269053a1bc3d9710811aeea /Doc/library
parent52bc7b85fd70eeaefaaa99a6595f864472a7e83a (diff)
downloadcpython-d47442e3cb9ba6eda8cca49d2f08a192f1f64e9f.zip
cpython-d47442e3cb9ba6eda8cca49d2f08a192f1f64e9f.tar.gz
cpython-d47442e3cb9ba6eda8cca49d2f08a192f1f64e9f.tar.bz2
Update itertools recipes to use next().
Diffstat (limited to 'Doc/library')
-rw-r--r--Doc/library/itertools.rst13
1 files changed, 6 insertions, 7 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index 299d769..2b1e747 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -321,14 +321,14 @@ loops that truncate the stream.
return self
def next(self):
while self.currkey == self.tgtkey:
- self.currvalue = self.it.next() # 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 = self.it.next() # Exit on StopIteration
+ self.currvalue = next(self.it) # Exit on StopIteration
self.currkey = self.keyfunc(self.currvalue)
.. versionadded:: 2.4
@@ -378,7 +378,7 @@ loops that truncate the stream.
# imap(pow, (2,3,10), (5,2,3)) --> 32 9 1000
iterables = map(iter, iterables)
while True:
- args = [it.next() for it in iterables]
+ args = [next(it) for it in iterables]
if function is None:
yield tuple(args)
else:
@@ -404,11 +404,11 @@ loops that truncate the stream.
# islice('ABCDEFG', 0, None, 2) --> A C E G
s = slice(*args)
it = iter(xrange(s.start or 0, s.stop or sys.maxint, s.step or 1))
- nexti = it.next()
+ nexti = next(it)
for i, element in enumerate(iterable):
if i == nexti:
yield element
- nexti = it.next()
+ nexti = next(it)
If *start* is ``None``, then iteration starts at zero. If *step* is ``None``,
then the step defaults to one.
@@ -738,8 +738,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 izip(a, b)
def grouper(n, iterable, fillvalue=None):