geoffroygivry
10/11/2017 - 9:45 AM

complex permutation of lists into a dict

import itertools
name = None
version = None
task = None
tag = None
permut_list = []
a = [["latest","not_latest","all"],[name is None, name is not None],[version is None, version is not None], [task is None, task is not None], [tag is None, tag is not None]]
permuts = list(itertools.product(*a))
keys = ['published', "name", "version", "task", "tag"]
for x in permuts:
    my_dict = dict(zip(keys, x))
    permut_list.append(my_dict)
print(permut_list)