code: def on(self, event, handler=None):
          
          if isinstance(event, str) and ' ' in event:  # event is list str-based
              self.on(event.split(' '), handler)
          elif isinstance(event, list):  # many events contains same handler
              for each in event:
                  self.on(each, handler)
          elif isinstance(event, dict):  # event is a dict of <event, handler>
              for key, value in event.items():
                  self.on(key, value)
          elif isinstance(handler, list):  # handler is a list of handlers
              for each in handler:
                  self.on(event, each)
          elif isinstance(handler, Event):  # handler is Event object
              self.events[event] = handler  # add or update an event
              setattr(self, event, self.events[event])  # self.event.trigger()
          elif event in self.events:  # add a handler to an existing event
              self.events[event].on(handler)
          else:  # create new event with a handler attached
              self.on(event, Event(handler))
docs: Create, add or update an event with a handler or more attached.