April 23, 2012
7:55 p.m.
On Apr 23, 2012, at 9:52 AM, Steven D'Aprano wrote:
However, the discoverability of this solution is essentially zero
That exact code has been in the documentation for years: def powerset(iterable): "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)" s = list(iterable) return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) The whole purpose of the itertools recipes are to teach how the itertools can be readily combined to build new tools. http://docs.python.org/library/itertools.html#module-itertools Raymond