code: def from_string(cls, string, *, default_func=None):
          '''Construct a NetAddress from a string and return a (host, port) pair.
  
          If either (or both) is missing and default_func is provided, it is called with
          ServicePart.HOST or ServicePart.PORT to get a default.
          '''
          if not isinstance(string, str):
              raise TypeError(f'address must be a string: {string}')
          host, port = _split_address(string)
          if default_func:
              host = host or default_func(ServicePart.HOST)
              port = port or default_func(ServicePart.PORT)
              if not host or not port:
                  raise ValueError(f'invalid address string: {string}')
          return cls(host, portf from_string(cls, string, *, default_func=None):
          '''Construct a NetAddress from a string and return a (host, port) pair.
  
          If either (or both) is missing and default_func is provided, it is called with
          ServicePart.HOST or ServicePart.PORT to get a default.
          '''
          if not isinstance(string, str):
              raise TypeError(f'address must be a string: {string}')
          host, port = _split_address(string)
          if default_func:
              host = host or default_func(ServicePart.HOST)
              port = port or default_func(ServicePart.PORT)
              if not host or not port:
                  raise ValueError(f'invalid address string: {string}')
          return cls(host, port)
docs: Construct a NetAddress from a string and return a (host, port) pair.
  
          If either (or both) is missing and default_func is provided, it is called with
          ServicePart.HOST or ServicePart.PORT to get a default.