human
Complete this python program:
def get_hostname(module=None, version=None, instance=None):
assistant
#Here is the Python code you requested.

    """Returns a hostname to use to contact the module.
    Args:
    module: Name of module, if None, take module of the current instance.
    version: Name of version, if version is None then either use the version of
    the current instance if that version exists for the target module,
    otherwise use the default version of the target module.
    instance: Instance to construct a hostname for, if instance is None, a
    loadbalanced hostname for the module will be returned.  If the target
    module is not a fixed module, then instance is not considered valid.
    Returns:
    A valid canonical hostname that can be used to communicate with the given
    module/version/instance.  E.g. 0.v1.module5.myapp.appspot.com
    Raises:
    InvalidModuleError: if the given moduleversion is invalid.
    InvalidInstancesError: if the given instance value is invalid.
    TypeError: if the given instance type is invalid.
    """
    def _ResultHook(rpc):
        mapped_errors = [modules_service_pb.ModulesServiceError.INVALID_MODULE, modules_service_pb.ModulesServiceError.INVALID_INSTANCES]
        _CheckAsyncResult(rpc, mapped_errors, [])
        return rpc.response.hostname()
    request = modules_service_pb.GetHostnameRequest()
    if module:
        request.set_module(module)
    if version:
        request.set_version(version)
    if (instance or (instance == 0)):
        if (not isinstance(instance, (basestring, long, int))):
            raise TypeError("'instance'    arg    must    be    of    type    basestring,    long    or    int.")
        request.set_instance(str(instance))
    response = modules_service_pb.GetHostnameResponse()
    return _MakeAsyncCall('GetHostname', request, response, _ResultHook).get_result()