def connect(self, receiver, sender=ANY, weak=True):
        """Connect *receiver* to signal events send by *sender*.

        :param receiver: A callable.  Will be invoked by :meth:`send`.
          Will be invoked with `sender=` as a named argument and any
          \*\*kwargs that were provided to a call to :meth:`send`.

        :param sender: Any object or :attr:`Signal.ANY`.  Restricts
          notifications to *receiver* to only those :meth:`send`
          emissions sent by *sender*.  If ``ANY``, the receiver will
          always be notified.  A *receiver* may be connected to
          multiple *sender* on the same Signal.  Defaults to ``ANY``.

        :param weak: If true, the Signal will hold a weakref to
          *receiver* and automatically disconnect when *receiver* goes
          out of scope or is garbage collected.  Defaults to True.

        """
        receiver_id = _hashable_identity(receiver)
        if weak:
            receiver_ref = weakrefs.reference(receiver, self._cleanup_receiver)
            receiver_ref.receiver_id = receiver_id
        else:
            receiver_ref = receiver
        sender_id = ANY_ID if sender is ANY else _hashable_identity(sender)

        self.receivers.setdefault(receiver_id, receiver_ref)
        self._by_sender[sender_id].add(receiver_id)
        self._by_receiver[receiver_id].add(sender_id)
        del receiver_ref

        if sender is not ANY and self._weak_senders not in sender_id:
            # wire together a cleanup for weakref-able senders
            try:
                sender_ref = weakrefs.reference(sender, self._cleanup_sender)
                sender_ref.sender_id = sender_id
            except TypeError:
                pass
            else:
                self._weak_senders.setdefault(sender_id, sender_ref)
                del sender_ref

        # broadcast this connection.  if receivers raise, disconnect.
        if receiver_connected.receivers and self is not receiver_connected:
            try:
                receiver_connected.send(self,
                                        receiver_arg=receiver,
                                        sender_arg=sender,
                                        weak_arg=weak)
            except:
                self.disconnect(receiver, sender)
                raise
        return receiver
dataset/ETHPy150Open jek/flatland/flatland/util/signals.py/Signal.connect/swapped operands of `not in`