def remap_keys(key_func, d):
    """
    Create a new dictionary by passing the keys from an old dictionary through a function.
    """
    return dict((key_func(key), value) for key, value in d.items())