mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Add some cross-references to the docs. Simplify the python code equivalent for zip(). Supply an optional argument for the nth() recipe.
This commit is contained in:
parent
d75fcb4ddf
commit
cdf8ba369b
3 changed files with 16 additions and 11 deletions
|
|
@ -1419,9 +1419,9 @@ Samuele
|
|||
... "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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue