def match_pattern(expr_or_pattern: object, expr: object) -> MatchDict:
    """Recursively match `expr` with the given `expr_or_pattern`

    Args:
        expr_or_pattern: either a direct expression (equal to `expr` for a
            successful match), or an instance of :class:`Pattern`.
        expr: the expression to be matched
    """
    try:  # first try expr_or_pattern as a Pattern
        return expr_or_pattern.match(expr)
    except AttributeError:  # expr_or_pattern is an expr, not a Pattern
        if expr_or_pattern == expr:
            return MatchDict()  # success
        else:
            res = MatchDict()
            res.success = False
            res.reason = "Expressions '%s' and '%s' are not the same" % (
                          repr(expr_or_pattern), repr(expr))
            return res
def match_pattern ( expr_or_pattern : object , expr : object ) -> MatchDict : try : return expr_or_pattern . match ( expr ) except AttributeError : if expr_or_pattern == expr : return MatchDict ( ) else : res = MatchDict ( ) res . success = False res . reason = "Expressions '%s' and '%s' are not the same" % ( repr ( expr_or_pattern ) , repr ( expr ) ) return res
Recursively match `expr` with the given `expr_or_pattern`

    Args:
        expr_or_pattern: either a direct expression (equal to `expr` for a
            successful match), or an instance of :class:`Pattern`.
        expr: the expression to be matched