On Sun, May 25, 2008 at 4:01 AM, Arnaud Delobelle firstname.lastname@example.org wrote:
On 23 May 2008, at 08:15, Carl Johnson wrote:
So, what do you think? Is this a common enough need that it should be built into itertools? The main namespace? Or should we leave it out, since adding it would encourage people writing O(n^x) algorithms? If nothing else, list members can enjoy rewriting this function for fun.
It is already in itertools:
Python 3.0a4+ (py3k:62388, Apr 19 2008, 15:34:00) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin Type "help", "copyright", "credits" or "license" for more information.
from itertools import product for v in product(*[[True, False]]*3):
... print(v) ... (True, True, True) (True, True, False) (True, False, True) (True, False, False) (False, True, True) (False, True, False) (False, False, True) (False, False, False)
Or a bit more readable:
for v in product([True, False], repeat=3):