def dict_filter(function, dictionary):
  """
  Filter dictionary by its key and value.

  Args:
    function: takes k, v as argument and returns True if that item should be
              included
    dictionary: python dict to filter
  """
  return {k: v for k, v in dictionary.items() if function(k, v)}