def getipaddrinfo(host):
 try:
  return [addrinfo for addrinfo in socket.getaddrinfo(host, None) if (((addrinfo[0] == socket.AF_INET) or (addrinfo[0] == socket.AF_INET6)) and isinstance(addrinfo[4][0], basestring))]
 except socket.error:
  return []

def getipaddrinfo ( host ) : try : return [ addrinfo for addrinfo in socket . getaddrinfo ( host , None ) if ( ( ( addrinfo [ 0 ] == socket . AF_INET ) or ( addrinfo [ 0 ] == socket . AF_INET6 ) ) and isinstance ( addrinfo [ 4 ] [ 0 ] , basestring ) ) ] except socket . error : return [ ]
filter out non-ip and bad ip addresses from getaddrinfo .