def lookup_family(hostname):
 fallback = socket.AF_INET
 try:
  hostnames = socket.getaddrinfo((hostname or None), None, socket.AF_UNSPEC, socket.SOCK_STREAM)
  if (not hostnames):
   return fallback
  h = hostnames[0]
  return h[0]
 except socket.gaierror:
  return fallback

def lookup_family ( hostname ) : fallback = socket . AF_INET try : hostnames = socket . getaddrinfo ( ( hostname or None ) , None , socket . AF_UNSPEC , socket . SOCK_STREAM ) if ( not hostnames ) : return fallback h = hostnames [ 0 ] return h [ 0 ] except socket . gaierror : return fallback
lookup a hostname and determine its address family .