def restrict_dict(d, keys):
 return {k: v for (k, v) in six.iteritems(d) if (k in keys)}

def restrict_dict ( d , keys ) : return { k : v for ( k , v ) in six . iteritems ( d ) if ( k in keys ) }
return a dictionary that contains those keys that appear in both d and keys .