summaryrefslogtreecommitdiffstats
path: root/Doc/library/itertools.rst
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2008-02-23 10:04:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2008-02-23 10:04:15 (GMT)
commit7832d4d534ff7105a0253694db734d5007b62e91 (patch)
treef97c7096d01997dfc5eaa63cba1aef04c013cf1d /Doc/library/itertools.rst
parent532316dfa6ae752e9211d28d1ef9a8d0399c018c (diff)
downloadcpython-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.rst6
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)
+