def select_ip_version(host, port):
 if ((':' in host) and hasattr(socket, 'AF_INET6')):
  return socket.AF_INET6
 return socket.AF_INET

def select_ip_version ( host , port ) : if ( ( ':' in host ) and hasattr ( socket , 'AF_INET6' ) ) : return socket . AF_INET6 return socket . AF_INET
returns af_inet4 or af_inet6 depending on where to connect to .