Minor doc fixes.

This commit is contained in:
Raymond Hettinger 2009-02-04 19:45:13 +00:00
parent 1c62dc9d73
commit d04fa31f73
4 changed files with 11 additions and 8 deletions

View file

@ -1371,8 +1371,8 @@ Samuele
... return map(function, count(start))
>>> def nth(iterable, n):
... "Returns the nth item or empty list"
... return list(islice(iterable, n, n+1))
... "Returns the nth item or None"
... return next(islice(iterable, n, None), None)
>>> def quantify(iterable, pred=bool):
... "Count how many times the predicate is true"
@ -1469,7 +1469,10 @@ perform as purported.
[0, 2, 4, 6]
>>> nth('abcde', 3)
['d']
'd'
>>> nth('abcde', 9) is None
True
>>> quantify(range(99), lambda x: x%2==0)
50