Commit 7832d4d5 authored by Raymond Hettinger's avatar Raymond Hettinger

Add recipe using itertools.product().

parent 532316df
...@@ -559,3 +559,9 @@ which incur interpreter overhead. :: ...@@ -559,3 +559,9 @@ which incur interpreter overhead. ::
pending -= 1 pending -= 1
nexts = cycle(islice(nexts, pending)) 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)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment