def clean_hosts(hosts, default_port=None):
 cleaned_hosts = []
 for cur_host in [host.strip() for host in hosts.split(',') if host.strip()]:
  cleaned_host = clean_host(cur_host, default_port)
  if cleaned_host:
   cleaned_hosts.append(cleaned_host)
 cleaned_hosts = (','.join(cleaned_hosts) if cleaned_hosts else '')
 return cleaned_hosts

def clean_hosts ( hosts , default_port = None ) : cleaned_hosts = [ ] for cur_host in [ host . strip ( ) for host in hosts . split ( ',' ) if host . strip ( ) ] : cleaned_host = clean_host ( cur_host , default_port ) if cleaned_host : cleaned_hosts . append ( cleaned_host ) cleaned_hosts = ( ',' . join ( cleaned_hosts ) if cleaned_hosts else '' ) return cleaned_hosts
returns list of cleaned hosts by clean_host .