def apply_policy(policy, r, name, sub):
 if isinstance(policy, (list, tuple)):
  ret = ''
  for sub_policy in policy:
   ret += sub_policy(r, name, sub)
  return ret
 return policy(r, name, sub)

def apply_policy ( policy , r , name , sub ) : if isinstance ( policy , ( list , tuple ) ) : ret = '' for sub_policy in policy : ret += sub_policy ( r , name , sub ) return ret return policy ( r , name , sub )
apply the list of policies to name .