from typing import OrderedDict
import itertools


def dictProduct(dicts):
    """
    Computes the Cartesian product of a dictionary of lists as
    a list of dictionaries.

    Gladly copied this code from:
    https://stackoverflow.com/questions/5228158/cartesian-product-of-a-dictionary-of-lists

    Example input:
    options = {"number": [1,2,3], "color": ["orange","blue"] }

    Example output:
    [ {"number": 1, "color": "orange"},
      {"number": 1, "color": "blue"},
      {"number": 2, "color": "orange"},
      {"number": 2, "color": "blue"},
      {"number": 3, "color": "orange"},
      {"number": 3, "color": "blue"}
    ]
    """
    dicts = OrderedDict(dicts)
    keys = list(dicts)
    return (OrderedDict(zip(keys, x)) for x in itertools.product(*dicts.values()))