diff options
author | Raymond Hettinger <python@rcn.com> | 2008-03-11 00:19:07 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-03-11 00:19:07 (GMT) |
commit | e8b4b605550441a17b8b2db3b9e3391b8752ce8d (patch) | |
tree | e9642e76459b5dc6169a299d9d8bed90b337a25b /Lib | |
parent | 0098c9d60997f40c8e75714db9963337dc834378 (diff) | |
download | cpython-e8b4b605550441a17b8b2db3b9e3391b8752ce8d.zip cpython-e8b4b605550441a17b8b2db3b9e3391b8752ce8d.tar.gz cpython-e8b4b605550441a17b8b2db3b9e3391b8752ce8d.tar.bz2 |
Add recipe to docs.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_itertools.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 696fdeb..3b5cc23 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1279,6 +1279,12 @@ Samuele ... for n in xrange(2**len(pairs)): ... yield set(x for m, x in pairs if m&n) +>>> def compress(data, selectors): +... "compress('abcdef', [1,0,1,0,1,1]) --> a c e f" +... for d, s in izip(data, selectors): +... if s: +... yield d + This is not part of the examples but it tests to make sure the definitions perform as purported. @@ -1353,6 +1359,9 @@ False >>> map(sorted, powerset('ab')) [[], ['a'], ['b'], ['a', 'b']] +>>> list(compress('abcdef', [1,0,1,0,1,1])) +['a', 'c', 'e', 'f'] + """ __test__ = {'libreftest' : libreftest} |