diff options
author | Raymond Hettinger <python@rcn.com> | 2008-07-19 23:21:57 +0000 |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-07-19 23:21:57 +0000 |
commit | 39e0eb766f02e18711d7eac9f948754a1ee569e3 (patch) | |
tree | 434853b0d4bc508925d85fc55a88f48b0357e587 /Lib/test/test_itertools.py | |
parent | d648f64a530a77db93df89cc03306ef80b27ff4f (diff) | |
download | cpython-git-39e0eb766f02e18711d7eac9f948754a1ee569e3.tar.gz |
Fix compress() recipe in docs to use itertools.
Diffstat (limited to 'Lib/test/test_itertools.py')
-rw-r--r-- | Lib/test/test_itertools.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/test/test_itertools.py b/Lib/test/test_itertools.py index 82e1ee43e8..2d07d8df0c 100644 --- a/Lib/test/test_itertools.py +++ b/Lib/test/test_itertools.py @@ -1281,9 +1281,9 @@ Samuele >>> 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 +... decorated = izip(data, selectors) +... filtered = ifilter(operator.itemgetter(1), decorated) +... return imap(operator.itemgetter(0), filtered) >>> def combinations_with_replacement(iterable, r): ... "combinations_with_replacement('ABC', 3) --> AA AB AC BB BC CC" |