def get_missing_permissions(user, permissions):
 if callable(getattr(user, 'has_perm', None)):
  missing_permissions = set((p for p in set(permissions) if (not user.has_perm(p))))
 else:
  missing_permissions = set(permissions)
 return missing_permissions

def get_missing_permissions ( user , permissions ) : if callable ( getattr ( user , 'has_perm' , None ) ) : missing_permissions = set ( ( p for p in set ( permissions ) if ( not user . has_perm ( p ) ) ) ) else : missing_permissions = set ( permissions ) return missing_permissions
return a set of missing permissions for a given iterable of permission strings .