def filter_keys(func, a_dict):
    """Return a copy of adict with only entries where the func(key) is True.

    Equivalent to the following in Python 3:
      {k:v for (k, v) in a_dict.items() if func(k)}
    """
    return dict((k, v) for (k, v) in a_dict.items() if func(k))