summaryrefslogtreecommitdiffstats
path: root/Doc/library/itertools.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2009-02-19 04:45:07 (GMT)
committerRaymond Hettinger <python@rcn.com>2009-02-19 04:45:07 (GMT)
commitcdf8ba369ba8a83bbf107f14185626797a6f4a95 (patch)
tree8015174a2c2d4896bbc4ba79583d93bc5443cc69 /Doc/library/itertools.rst
parentd75fcb4ddfb76b290083982e44b80582ab13aae2 (diff)
downloadcpython-cdf8ba369ba8a83bbf107f14185626797a6f4a95.zip
cpython-cdf8ba369ba8a83bbf107f14185626797a6f4a95.tar.gz
cpython-cdf8ba369ba8a83bbf107f14185626797a6f4a95.tar.bz2
Add some cross-references to the docs. Simplify the python code equivalent for zip(). Supply an optional argument for the nth() recipe.
Diffstat (limited to 'Doc/library/itertools.rst')
-rw-r--r--Doc/library/itertools.rst6
1 files changed, 3 insertions, 3 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index 491cb18..32ad792 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -615,9 +615,9 @@ which incur interpreter overhead.
"Return function(0), function(1), ..."
return map(function, count(start))
- def nth(iterable, n):
- "Returns the nth item or None"
- return next(islice(iterable, n, None), None)
+ def nth(iterable, n, default=None):
+ "Returns the nth item or a default value"
+ return next(islice(iterable, n, None), default)
def quantify(iterable, pred=bool):
"Count how many times the predicate is true"