Skip to content

Commit

Permalink
merges python 2.5 support, giving fallback for itertools.product
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunc committed Jan 18, 2011
1 parent 17f7411 commit 6921c99
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion freshen/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@
import os
import re
import textwrap
from itertools import product
try:
from itertools import product
except ImportError:
def product(*args, **kwds):
# product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
# product(range(2), repeat=3) --> 000 001 010 011 100 101 110 111
pools = map(tuple, args) * kwds.get('repeat', 1)
result = [[]]
for pool in pools:
result = [x+[y] for x in result for y in pool]
for prod in result:
yield tuple(prod)

try:
from os.path import relpath
Expand Down

0 comments on commit 6921c99

Please sign in to comment.