code: def connect(self, func=None, event=None, set_method=False):
          
          if func is None:
              return partial(self.connect, set_method=set_method)
  
          # Get the event name from the function.
          if event is None:
              event = self._get_on_name(func)
  
          # We register the callback function.
          self._callbacks[event].append(func)
  
          # A new method self.event() emitting the event is created.
          if set_method:
              self._create_emitter(event)
  
          return func
docs: Register a callback function to a given event.
  
          To register a callback function to the `spam` event, where `obj` is
          an instance of a class deriving from `EventEmitter`:
  
          ```python
          @obj.connect
          def on_spam(arg1, arg2):
              pass
          ```
  
          This is called when `obj.emit('spam', arg1, arg2)` is called.
  
          Several callback functions can be registered for a given event.
  
          The registration order is conserved and may matter in applications.