code: def on(self, handler):
          
          if not hasattr(handler, '__call__'):
              raise TypeError('handler is not a callable object.')
          self.handlers.add(handler)
docs: Attach a handler (any Python callable) for the event.