mirror of
https://github.com/python/cpython.git
synced 2025-10-10 08:53:14 +00:00
Fix nth() itertool recipe.
(backport from rev. 52497)
This commit is contained in:
parent
a35f8e0538
commit
aabdd5480c
1 changed files with 2 additions and 2 deletions
|
@ -474,8 +474,8 @@ def iteritems(mapping):
|
||||||
return izip(mapping.iterkeys(), mapping.itervalues())
|
return izip(mapping.iterkeys(), mapping.itervalues())
|
||||||
|
|
||||||
def nth(iterable, n):
|
def nth(iterable, n):
|
||||||
"Returns the nth item"
|
"Returns the nth item or raise IndexError"
|
||||||
return list(islice(iterable, n, n+1))
|
return list(islice(iterable, n, n+1))[0]
|
||||||
|
|
||||||
def all(seq, pred=None):
|
def all(seq, pred=None):
|
||||||
"Returns True if pred(x) is true for every element in the iterable"
|
"Returns True if pred(x) is true for every element in the iterable"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue