def _check_varname(self, name):
        """ Verifies that a variable name is valid. Also checks for
        duplicates."""
        if self._post_setup_vars:
            raise RuntimeError("%s: can't add variable '%s' because setup has already been called." %
                               (self.pathname, name))
        if name in self._init_params_dict or name in self._init_unknowns_dict:
            raise RuntimeError("%s: variable '%s' already exists." %
                               (self.pathname, name))

        match = namecheck_rgx.match(name)
        if match is None or match.group() != name:
            raise NameError("%s: '%s' is not a valid variable name." %
                            (self.pathname, name))
dataset/ETHPy150Open OpenMDAO/OpenMDAO/openmdao/core/component.py/Component._check_varname/original