import itertools as it
varNames = sorted(variants)
combinations = [dict(zip(varNames, prod)) for prod in it.product(*(variants[varName] for varName in varNames))]
Hm, this returns:
[{'debug': 'on', 'locale': 'de_DE'},
{'debug': 'on', 'locale': 'en_US'},
{'debug': 'on', 'locale': 'fr_FR'},
{'debug': 'off', 'locale': 'de_DE'},
{'debug': 'off', 'locale': 'en_US'},
{'debug': 'off', 'locale': 'fr_FR'}]
which is probably not exactly, what you want. Let me adapt it...
combinations = [ [ {varName: val} for varName, val in zip(varNames, prod) ] for prod in it.product(*(variants[varName] for varName in varNames))]
returns now:
[[{'debug': 'on'}, {'locale': 'de_DE'}],
[{'debug': 'on'}, {'locale': 'en_US'}],
[{'debug': 'on'}, {'locale': 'fr_FR'}],
[{'debug': 'off'}, {'locale': 'de_DE'}],
[{'debug': 'off'}, {'locale': 'en_US'}],
[{'debug': 'off'}, {'locale': 'fr_FR'}]]
Voilà ;-)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…