def update_merge_tags(mailchimp, list_id, tag_names):
 mc_vars = mailchimp.listMergeVars(id=list_id)
 mc_names = set((v['name'] for v in mc_vars))
 mc_merge = mailchimp.listMergeVarAdd
 tags = [v['tag'] for v in mc_vars]
 for name in tag_names:
  tag = name_to_tag(name)
  if ('FULLNAME' not in tags):
   result = mc_merge(id=list_id, tag='FULLNAME', name='Full Name', options={'field_type': 'text', 'public': False})
   tags.append('FULLNAME')
   log.debug(result)
  if ((name not in mc_names) and (tag not in ['EMAIL', 'FULLNAME'])):
   ftype = FIELD_TYPES.get(name, 'number')
   result = mc_merge(id=list_id, tag=tag, name=name, options={'field_type': ftype, 'public': False})
   tags.append(tag)
   log.debug(result)

def update_merge_tags ( mailchimp , list_id , tag_names ) : mc_vars = mailchimp . listMergeVars ( id = list_id ) mc_names = set ( ( v [ 'name' ] for v in mc_vars ) ) mc_merge = mailchimp . listMergeVarAdd tags = [ v [ 'tag' ] for v in mc_vars ] for name in tag_names : tag = name_to_tag ( name ) if ( 'FULLNAME' not in tags ) : result = mc_merge ( id = list_id , tag = 'FULLNAME' , name = 'Full Name' , options = { 'field_type' : 'text' , 'public' : False } ) tags . append ( 'FULLNAME' ) log . debug ( result ) if ( ( name not in mc_names ) and ( tag not in [ 'EMAIL' , 'FULLNAME' ] ) ) : ftype = FIELD_TYPES . get ( name , 'number' ) result = mc_merge ( id = list_id , tag = tag , name = name , options = { 'field_type' : ftype , 'public' : False } ) tags . append ( tag ) log . debug ( result )
this function is rather inscrutable .