<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def client_for(service, service_module, thrift_service_name=None):
 """Build a client class for the given Thrift service. The generated class accepts a TChannel and an optional hostport as initialization arguments. Given ``CommentService`` defined in ``comment.thrift`` and registered with Hyperbahn under the name "comment", here's how this may be used: .. code-block:: python from comment import CommentService CommentServiceClient = client_for("comment", CommentService) @gen.coroutine def post_comment(articleId, msg, hostport=None):
 client = CommentServiceClient(tchannel, hostport) yield client.postComment(articleId, CommentService.Comment(msg)) :param service: Name of the Hyperbahn service being called. This is the name with which the service registered with Hyperbahn. :param service_module: The Thrift-generated module for that service. This usually has the same name as defined for the service in the IDL. :param thrift_service_name: If the Thrift service has a different name than its module, use this parameter to specify it. :returns: An object with the same interface as the service that uses the given TChannel to call the service. """

    assert service_module, 'service_module is required'
    service = service or ''  # may be blank for non-hyperbahn use cases
    if not thrift_service_name:
        thrift_service_name = service_module.__name__.rsplit('.', 1)[-1]

    method_names = get_service_methods(service_module.Iface)

    def new(cls, tchannel, hostport=None, trace=False, protocol_headers=None):
        """
        :param tchannel:
            TChannel through which the requests will be sent.
        :param hostport:
            Address of the machine to which the requests will be sent, or None
            if the TChannel will do peer selection on a per-request basis.
        :param trace:
            Whether tracing is enabled.
        :param protocol_headers:
            Protocol-level headers to send with the request.
        """
        protocol_headers = protocol_headers or {}
        protocol_headers['as'] = 'thrift'
        return _ClientBase.__new__(
            cls, tchannel, hostport, service, trace, protocol_headers
        )

    new.__name__ = '__new__'
    methods = {'__new__': new}

    for method_name in method_names:
        methods[method_name] = generate_method(
            service_module, thrift_service_name, method_name
        )

    return type(thrift_service_name + 'Client', (_ClientBase,), methods)