def str2list(string):
 if ((',' in string) or ('|' in string)):
  return string.replace('|', ',').split(',')
 return string

def str2list ( string ) : if ( ( ',' in string ) or ( '|' in string ) ) : return string . replace ( '|' , ',' ) . split ( ',' ) return string
this function takes a string and returns either this string or a list of the coma-or-pipe separated elements from the string .