What is the output of the following? “`python class EventMixin: def trigger(self, name): handler = getattr(self, f’on_{name}’, None) if callable(handler): return handler() return None class App(EventMixin): def on_start(self): return ‘started’ app = App() print(app.trigger(‘start’)) print(app.trigger(‘stop’)) “`
Key points
- The EventMixin class triggers events based on method names.
- App class inherits from EventMixin and defines the 'on_start' method.
- The 'trigger' method in EventMixin checks for the handler and calls it if it's callable.
Ready to go further?
