def paste_as(self, key, data):
        """Paste and transform data

        Data may be given as a Python code as well as a tab separated
        multi-line strings similar to paste.

        """

        def error_msg(err):
            msg = _("Error evaluating data: ") + str(err)
            post_command_event(self.main_window, self.StatusBarMsg, text=msg)

        interfaces = self.main_window.interfaces
        key = self.main_window.grid.actions.cursor

        try:
            obj = ast.literal_eval(data)

        except (SyntaxError, AttributeError):
            # This is no Python code so te try to interpret it as paste data
            try:
                obj = [map(ast.literal_eval, line.split("\t"))
                       for line in data.split("\n")]

            except Exception, err:
                # This must just be text.
                try:
                    obj = [line.split('\t') for line in data.split('\n')]
                except Exception, err:
                    # Now I really have no idea
                    error_msg(err)
                    return

        except ValueError, err:
            error_msg(err)
            return

        parameters = interfaces.get_pasteas_parameters_from_user(obj)

        if parameters is None:
            # Dialog aborted
            return

        paste_data = self._get_pasteas_data(parameters["dim"], obj)

        if parameters["transpose"]:
            paste_data = zip(*paste_data)

        self.main_window.grid.actions.paste(key, paste_data, freq=1000)
Paste and transform data

        Data may be given as a Python code as well as a tab separated
        multi-line strings similar to paste.