python - All possible tuples -
python - All possible tuples -
possible_frequency = [0,1,2,3,4,5,6,7,8] clamp_range = list(xrange(0, 51, 1)) possible_clamp_levels = int(len(clamp_range)*len(possible_frequency)) print possible_clamp_levels
i want find way print possible tuples (459) using possible_frequency
, clamp_range
is, (0,0),(0,1), (0,2).....(8, 50)
is there bundle in python allow me this.
this do
possible_tuples = []
for in range(0, len(possible_frequency)): b in range(0, len(clamp_range)): test = (possible_frequency[a], clamp_range[b]) possible_tuples.append(test) print possible_tuples
i need more sophisticated way.
you can utilize itertools.product()
:
from itertools import product list(product(possible_frequency, clamp_range))
python itertools
Comments
Post a Comment