def matching_subset(main, sub):
    """check that all the keys in a dictionary are in sub and agree with main
    Example:
        main = {"a": 3, "b": 4, "c": 10}
        sub1 = {"a": 3, "c": 10}
        sub2 = {"a": 3, "foo": 5}
        sub3 = {"a": 0, "b": 1}
    sub1 is a "matching subset" of main since all its keys match with main
    sub2 is not a "matching subset" of main since the field "foo" is not in main
    sub3 is not a "matching subset" since sub3["a"] = 0 but main["a"] == 3
    """
    # check that all keys of sub are in main
    main_keys = set(main)
    sub_keys = set(sub)
    if not sub_keys.issubset(main_keys):
        return False
    # check that all values of sub match with main
    for key in sub_keys:
        if main[key] != sub[key]:
            return False
    return True