[Python-checkins] r60973 - python/trunk/Doc/library/itertools.rst

raymond.hettinger python-checkins at python.org
Sat Feb 23 11:04:16 CET 2008


Author: raymond.hettinger
Date: Sat Feb 23 11:04:15 2008
New Revision: 60973

Modified:
   python/trunk/Doc/library/itertools.rst
Log:
Add recipe using itertools.product().

Modified: python/trunk/Doc/library/itertools.rst
==============================================================================
--- python/trunk/Doc/library/itertools.rst	(original)
+++ python/trunk/Doc/library/itertools.rst	Sat Feb 23 11:04:15 2008
@@ -559,3 +559,9 @@
                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)
+


More information about the Python-checkins mailing list