diff options
author | Raymond Hettinger <python@rcn.com> | 2008-02-23 10:04:15 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2008-02-23 10:04:15 (GMT) |
commit | 7832d4d534ff7105a0253694db734d5007b62e91 (patch) | |
tree | f97c7096d01997dfc5eaa63cba1aef04c013cf1d /Doc/library/itertools.rst | |
parent | 532316dfa6ae752e9211d28d1ef9a8d0399c018c (diff) | |
download | cpython-7832d4d534ff7105a0253694db734d5007b62e91.zip cpython-7832d4d534ff7105a0253694db734d5007b62e91.tar.gz cpython-7832d4d534ff7105a0253694db734d5007b62e91.tar.bz2 |
Add recipe using itertools.product().
Diffstat (limited to 'Doc/library/itertools.rst')
-rw-r--r-- | Doc/library/itertools.rst | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst index 7d1ec96..5cc3e08 100644 --- a/Doc/library/itertools.rst +++ b/Doc/library/itertools.rst @@ -559,3 +559,9 @@ which incur interpreter overhead. :: pending -= 1 nexts = cycle(islice(nexts, pending)) + def powerset(iterable): + "powerset('ab') --> set([]), set(['b']), set(['a']), set(['a', 'b'])" + skip = object() + for t in product(*izip(repeat(skip), iterable)): + yield set(e for e in t if e is not skip) + |