def host_to_ips(host):
 ips = []
 try:
  for (family, socktype, proto, canonname, sockaddr) in socket.getaddrinfo(host, 0, socket.AF_UNSPEC, socket.SOCK_STREAM):
   if (family == socket.AF_INET):
    (ip, port) = sockaddr
   elif (family == socket.AF_INET6):
    (ip, port, flow_info, scope_id) = sockaddr
   ips.append(ip)
  if (not ips):
   ips = None
 except Exception:
  ips = None
 return ips

def host_to_ips ( host ) : ips = [ ] try : for ( family , socktype , proto , canonname , sockaddr ) in socket . getaddrinfo ( host , 0 , socket . AF_UNSPEC , socket . SOCK_STREAM ) : if ( family == socket . AF_INET ) : ( ip , port ) = sockaddr elif ( family == socket . AF_INET6 ) : ( ip , port , flow_info , scope_id ) = sockaddr ips . append ( ip ) if ( not ips ) : ips = None except Exception : ips = None return ips
returns a list of ip addresses of a given hostname or none if not found .