mirror of
https://github.com/python/cpython.git
synced 2025-09-12 19:57:40 +00:00
Add some cross-references to the docs. Simplify the python code equivalent for izip(). Supply an optional argument for the nth() recipe.
This commit is contained in:
parent
182edaefb5
commit
f9bce83e71
3 changed files with 16 additions and 10 deletions
|
@ -1401,9 +1401,9 @@ Samuele
|
|||
... "Return function(0), function(1), ..."
|
||||
... return imap(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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue