def af_for_address(text):
 try:
  junk = dns.ipv4.inet_aton(text)
  return AF_INET
 except:
  try:
   junk = dns.ipv6.inet_aton(text)
   return AF_INET6
  except:
   raise ValueError

def af_for_address ( text ) : try : junk = dns . ipv4 . inet_aton ( text ) return AF_INET except : try : junk = dns . ipv6 . inet_aton ( text ) return AF_INET6 except : raise ValueError
determine the address family of a textual-form network address .