Python decorator to determine order of execution of methods
问题 I have a basic class Framework with 3 methods that can be set by the user: initialize , handle_event and finalize . These methods are executed by the method run : class Framework(object): def initialize(self): pass def handle_event(self, event): pass def finalize(self): pass def run(self): self.initialize() for event in range(10): self.handle_event(event) self.finalize() I would like to create 3 decorators: on_initialize , on_event and on_finalize so that I could write such a class: class