[Python-checkins] r69908 - python/trunk/Doc/library/itertools.rst
raymond.hettinger
python-checkins at python.org
Mon Feb 23 20:32:55 CET 2009
Author: raymond.hettinger
Date: Mon Feb 23 20:32:55 2009
New Revision: 69908
Log:
Update itertools recipes to use next().
Modified:
python/trunk/Doc/library/itertools.rst
Modified: python/trunk/Doc/library/itertools.rst
==============================================================================
--- python/trunk/Doc/library/itertools.rst (original)
+++ python/trunk/Doc/library/itertools.rst Mon Feb 23 20:32:55 2009
@@ -321,14 +321,14 @@
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 @@
# 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 @@
# 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 @@
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):
More information about the Python-checkins
mailing list