Mistři v programování na #hovnokod

Python #335

class SomeServer:
    def __init__(self, ...)
        self.__dispatcher = {"CMD1" : self.invoke_cmd1_command, \
                             "CMD2" : self.invoke_cmd2_command, \
                             "CMD3" : self.invoke_cmd3_command, \
                             "CMD4" : self.invoke_cmd4_command, \
                              ... : ...}


    def handle_some_request(self, request):
        command, arguments = extract_command_and_arguments(request)
        try:
            self.__dispatcher[command](command, arguments)
        except Exception as e:
            ... log it ...
            ... return error to client...
            ... whatever ...

HovnoKod,