Commit 5482db66 authored by Denis Bilenko's avatar Denis Bilenko

cythonpp.py: drop support for python2.5

parent 54d409df
......@@ -8,6 +8,7 @@ import datetime
import pipes
import difflib
from hashlib import md5
from itertools import combinations, product
do_exec = None
if sys.version_info >= (3, 0):
......@@ -725,41 +726,6 @@ def dbg(*args):
return log(*args)
# itertools is not available on python 2.5
# itertools.combinations has a problem on 2.6.1
def combinations(iterable, r):
# combinations('ABCD', 2) --> AB AC AD BC BD CD
# combinations(range(4), 3) --> 012 013 023 123
pool = tuple(iterable)
n = len(pool)
if r > n:
return
indices = list(range(r))
yield tuple(pool[i] for i in indices)
while True:
for i in reversed(range(r)):
if indices[i] != i + n - r:
break
else:
return
indices[i] += 1
for j in range(i + 1, r):
indices[j] = indices[j - 1] + 1
yield tuple(pool[i] for i in indices)
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 = tuple(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)
if __name__ == '__main__':
import optparse
parser = optparse.OptionParser()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment