def filter_dict_by_key ( d , keys ) : return { k : v for k , v in d . items ( ) if k in keys }
python filtering keys in dict
Filter the dict * d * to remove keys not in * keys * .
def filter_dict_by_key(d, keys):
    """Filter the dict *d* to remove keys not in *keys*."""
    return {k: v for k, v in d.items() if k in keys}