Python : Most efficient way to get list of combinations? -
i have dictionary :
diff_params = {0: [a, b], 1: [c, d]} each key setting_name, , each value specific setting. able make list like:
[[a, c], [a, d], [b, c], [b, d]] i can't figure out how cleanly when have 3 or 4 or 5 settings , each setting has several options.
it seems more looking itertools.product() can used unpacking:
from itertools import product result = product(*diff_params.values()) you may need cast result if want list of list (surrounding list useless if using python 2 because map() return list):
result = list(map(list, result))
Comments
Post a Comment