def mapdict(itemfunc, dictionary):
    """
    Much like the builtin function 'map', but works on dictionaries.
    *itemfunc* should be a function which takes one parameter, a (key,
    value) pair, and returns a new (or same) (key, value) pair to go in
    the dictionary.
    """
    return dict(map(itemfunc, dictionary.items()))