Python function pointers within the same Class
问题 I have the following class in Python that I am trying to use for calling a set of its own methods through a dictionary that has the pointers of the available functions: class Test(): functions = { 'operation_a' : Test.function_a; 'operation_b' : Test.function_b; } def run_operations(operation, *args, **kwargs): try: functions[str(operation)](self, args, kwargs) except KeyError: // some log ... def function_a(self, *args, **kwargs): print A def function_b(self, *args, **kwargs): print B This