human
I wrote the below code

    check_environ()
    def _subst(match, local_vars=local_vars):
        var_name = match.group(1)
        if (var_name in local_vars):
            return str(local_vars[var_name])
        else:
            return os.environ[var_name]
    try:
        return re.sub('\\$([a-zA-Z_][a-zA-Z_0-9]*)', _subst, s)
    except KeyError as var:
        raise ValueError(("invalid    variable    '$%s'" % var))

What's a good function header?
assistant
#Here's a good function header.

def subst_vars(s, local_vars):