summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2006-10-28 16:04:07 +0000
committerGeorg Brandl <georg@python.org>2006-10-28 16:04:07 +0000
commitaabdd5480c23120eae18cdf1c45ae71814ac2eb9 (patch)
tree99d87a163bf8b242111d626fceb6235888c62775
parenta35f8e05382aa53b98f423b918ae5f4bd030923a (diff)
downloadcpython-git-aabdd5480c23120eae18cdf1c45ae71814ac2eb9.tar.gz
Fix nth() itertool recipe.
(backport from rev. 52497)
-rw-r--r--Doc/lib/libitertools.tex4
1 files changed, 2 insertions, 2 deletions
diff --git a/Doc/lib/libitertools.tex b/Doc/lib/libitertools.tex
index 20bbc8dd76..59fbd98844 100644
--- a/Doc/lib/libitertools.tex
+++ b/Doc/lib/libitertools.tex
@@ -474,8 +474,8 @@ def iteritems(mapping):
return izip(mapping.iterkeys(), mapping.itervalues())
def nth(iterable, n):
- "Returns the nth item"
- return list(islice(iterable, n, n+1))
+ "Returns the nth item or raise IndexError"
+ return list(islice(iterable, n, n+1))[0]
def all(seq, pred=None):
"Returns True if pred(x) is true for every element in the iterable"