@register('<STR_LIT>')<EOL>@register('<STR_LIT>')<EOL>def resolvepy(<EOL>expr,<EOL>safe=DEFAULT_SAFE, tostr=DEFAULT_TOSTR, scope=DEFAULT_SCOPE,<EOL>besteffort=DEFAULT_BESTEFFORT<EOL>):
result = None<EOL>_eval = safe_eval if safe else eval<EOL>_expr = expr<EOL>scope = {} if scope is None else scope.copy()<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>result = _eval(_expr, scope)<EOL><DEDENT>except (AttributeError, NameError) as nex:<EOL><INDENT>if not besteffort:<EOL><INDENT>raise<EOL><DEDENT>arg = nex.args[<NUM_LIT:0>]<EOL>missing = MISSING_NAME_REGEX.findall(arg)[-<NUM_LIT:1>]<EOL>try:<EOL><INDENT>_expr = sub(<EOL>MISSING_VARIABLE.format(missing),<EOL>genrepl(scope=scope),<EOL>_expr<EOL>)<EOL><DEDENT>except ImportError:<EOL><INDENT>raise nex<EOL><DEDENT><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if tostr:<EOL><INDENT>result = str(result)<EOL><DEDENT>return result<EOL>
Resolve input expression.

    :param str expr: configuration expression to resolve in this language.
    :param bool safe: safe run execution context (True by default).
    :param bool tostr: format the result.
    :param dict scope: execution scope (contains references to expression
        objects).
    :param bool besteffort: try to resolve unknown variable name with execution
        runtime.