def add_response(self, expr, name=None, scope=None):
        """Adds a response to the driver.

        expr: string
            String containing the response expression.

        name: string (optional)
            Name to be used to refer to the response in place of the expression
            string.

        scope: object (optional)
            The object to be used as the scope when evaluating the expression.

        """
        expr = _remove_spaces(expr)
        if expr in self._responses:
            self.parent.raise_exception("Trying to add response '%s' to"
                                        " driver, but it's already there"
                                        % expr, AttributeError)
        if name is not None and name in self._responses:
            self.parent.raise_exception("Trying to add response '%s' to"
                                        " driver using name '%s', but name is"
                                        " already used" % (expr, name),
                                        AttributeError)

        scope = self._get_scope(scope)
        try:
            expreval = Response(expr, scope)
            unresolved_vars = expreval.get_unresolved()
        except __HOLE__:
            unresolved_vars = [expr]
        if unresolved_vars:
            msg = "Can't add response '{0}' because of invalid variables {1}"
            error = ConnectedExprEvaluator._invalid_expression_error(unresolved_vars,
                                                                     expr, msg)
            self.parent.raise_exception(str(error), type(error))

        name = expr if name is None else name

        #expreval.activate(self.parent)

        self._responses[name] = expreval
        self.parent.config_changed()
dataset/ETHPy150Open OpenMDAO/OpenMDAO-Framework/openmdao.main/src/openmdao/main/hasresponses.py/HasResponses.add_response