def dict_pick ( dictionary , allowed_keys ) : return { key : value for key , value in viewitems ( dictionary ) if key in allowed_keys }
python restrict values in a dict
Return a dictionary only with keys found in allowed_keys
def dict_pick(dictionary, allowed_keys):
    """
    Return a dictionary only with keys found in `allowed_keys`
    """
    return {key: value for key, value in viewitems(dictionary) if key in allowed_keys}