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:
Raymond Hettinger 2009-02-19 05:34:35 +00:00
parent 182edaefb5
commit f9bce83e71
3 changed files with 16 additions and 10 deletions

View file

@ -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"