diff options
author | Raymond Hettinger <python@rcn.com> | 2003-08-08 04:33:19 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-08-08 04:33:19 (GMT) |
commit | 77fe69bd082496151debfbd369864e71bbd58de2 (patch) | |
tree | 774024d93656ecc72220e5111f5a01c0d6447279 /Lib/test/test_itertools.py | |
parent | c7d7766fda5d08f00ac4d46c5a9d5d4361e8038d (diff) | |
download | cpython-77fe69bd082496151debfbd369864e71bbd58de2.zip cpython-77fe69bd082496151debfbd369864e71bbd58de2.tar.gz cpython-77fe69bd082496151debfbd369864e71bbd58de2.tar.bz2 |
Re-sync doc tests with the doc updates.
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r-- | Lib/test/test_itertools.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 728380d..52ae110 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -471,15 +471,19 @@ Samuele >>> def all(pred, seq): ... "Returns True if pred(x) is True for every element in the iterable" -... return not nth(ifilterfalse(pred, seq), 0) +... return False not in imap(pred, seq) >>> def some(pred, seq): ... "Returns True if pred(x) is True for at least one element in the iterable" -... return bool(nth(ifilter(pred, seq), 0)) +... return True in imap(pred, seq) >>> def no(pred, seq): ... "Returns True if pred(x) is False for every element in the iterable" -... return not nth(ifilter(pred, seq), 0) +... return True not in imap(pred, seq) + +>>> def quantify(pred, seq): +... "Count how many times the predicate is True in the sequence" +... return sum(imap(pred, seq)) >>> def padnone(seq): ... "Returns the sequence elements and then returns None indefinitely" |