<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def sign(self, keypair):
 """Sign this transaction envelope with a given keypair. Note that the signature must not already be in this instance's list of signatures. :param keypair: The keypair to use for signing this transaction envelope. :type keypair: :class:`Keypair <stellar_base.keypair.Keypair>` :raises: :exc:`SignatureExistError <stellar_base.utils.SignatureExistError>` """

        assert isinstance(keypair, Keypair)
        tx_hash = self.hash_meta()
        sig = keypair.sign_decorated(tx_hash)
        sig_dict = [signature.__dict__ for signature in self.signatures]
        if sig.__dict__ in sig_dict:
            raise SignatureExistError('The keypair has already signed')
        else:
            self.signatures.append(sig)