def _address_family(address):
 if (address.startswith('[') and address.endswith(']')):
  return socket.AF_INET6
 for af in (socket.AF_INET, socket.AF_INET6):
  try:
   socket.inet_pton(af, address)
   return af
  except (ValueError, AttributeError, socket.error):
   continue
 return socket.AF_UNSPEC

def _address_family ( address ) : if ( address . startswith ( '[' ) and address . endswith ( ']' ) ) : return socket . AF_INET6 for af in ( socket . AF_INET , socket . AF_INET6 ) : try : socket . inet_pton ( af , address ) return af except ( ValueError , AttributeError , socket . error ) : continue return socket . AF_UNSPEC
attempt to determine the family of an address :return: either socket .