(hostnames, resolve=False)
return components
Converts a list of 'host[|ip]' entries into namedtuples containing 'host' and 'ip' attributes,
    optionally performing a DNS lookup to resolve the hostname into an IP address
    :param hostnames: a list of hostnames where each hostname can be of the form 'host[|ip]'
    :param resolve: boolean representing whether to lookup the IP address corresponding to the hostname via DNS
    :returns: a namedtuple containing the hostname and IP components
Converts a list of 'host[|ip]' entries into namedtuples containing 'host' and 'ip' attributes,
    optionally performing a DNS lookup to resolve the hostname into an IP address
    :param hostnames: a list of hostnames where each hostname can be of the form 'host[|ip]'
    :param resolve: boolean representing whether to lookup the IP address corresponding to the hostname via DNS
    :returns: a namedtuple containing the hostname and IP components
Converts a list of host [ |ip ] entries into namedtuples containing host and ip attributes optionally performing a DNS lookup to resolve the hostname into an IP address : param hostnames : a list of hostnames where each hostname can be of the form host [ |ip ] : param resolve : boolean representing whether to lookup the IP address corresponding to the hostname via DNS : returns : a namedtuple containing the hostname and IP components
def hostnames_to_components(hostnames, resolve=False):
    """Converts a list of 'host[|ip]' entries into namedtuples containing 'host' and 'ip' attributes,
    optionally performing a DNS lookup to resolve the hostname into an IP address
    :param hostnames: a list of hostnames where each hostname can be of the form 'host[|ip]'
    :param resolve: boolean representing whether to lookup the IP address corresponding to the hostname via DNS
    :returns: a namedtuple containing the hostname and IP components
    """

    components = []
    for hostname in hostnames:
        # This is to allow specifying a hostname as "hostname|ipaddress"
        # to avoid querying DNS for the IP.
        if "|" in hostname:
            (host, ip) = hostname.split("|")
            components.append(Hostname(host=host, ip=ip))
        else:
            ip = gethostbyname(hostname) if resolve else None
            components.append(Hostname(host=hostname, ip=ip))
    return components
def hostnames_to_components ( hostnames , resolve = False ) : components = [ ] for hostname in hostnames : # This is to allow specifying a hostname as "hostname|ipaddress" # to avoid querying DNS for the IP. if "|" in hostname : ( host , ip ) = hostname . split ( "|" ) components . append ( Hostname ( host = host , ip = ip ) ) else : ip = gethostbyname ( hostname ) if resolve else None components . append ( Hostname ( host = hostname , ip = ip ) ) return components