code: def host_type(host):
      
      if not host:
          return HOST_REG_NAME
      elif host[0] == '[':
          return HOST_IP_LITERAL
      elif __valid_IPv4address(host):
          return HOST_IPV4_ADDRESS
      else:
          return HOST_REG_NAME
docs: Correctly classify correct RFC 3986 compliant hostnames, but do not try
      hard to validate compliance anyway...
      NOTE: indeed we allow a small deviation from the RFC 3986: IPv4
      addresses are allowed to contain bytes represented in hexadecimal or
      octal notation when begining respectively with '0x'/'0X' and '0'
      numbers prepended with one or more zero won't be rejected.  Anyway
      representation of multiple bytes by a single decimal/octal/hexadecimal
      integer is not allowed.
  
      Return 1 (HOST_IP_LITERAL), 2 (HOST_IPV4_ADDRESS) or 3 (HOST_REG_NAME)
  
      >>> host_type('[blablabla]')
      1
      >>> host_type('')
      3
      >>> host_type('127.0.0.1')
      2
      >>> host_type('0x7F.0.0.00000000000001')
      2
      >>> host_type('666.42.131.2')
      3
      >>> host_type('foobar.42')
      3