summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_itertools.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2003-08-08 04:33:19 (GMT)
committerRaymond Hettinger <python@rcn.com>2003-08-08 04:33:19 (GMT)
commit77fe69bd082496151debfbd369864e71bbd58de2 (patch)
tree774024d93656ecc72220e5111f5a01c0d6447279 /Lib/test/test_itertools.py
parentc7d7766fda5d08f00ac4d46c5a9d5d4361e8038d (diff)
downloadcpython-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.py10
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"