def debug(rule, file=None):
    """ Print out before and after expressions each time rule is used """
    if file is None:
        from sys import stdout
        file = stdout
    def debug_rl(*args, **kwargs):
        expr = args[0]
        result = rule(*args, **kwargs)
        if result != expr:
            file.write("Rule: %s\n" % get_function_name(rule))
            file.write("In:   %s\nOut:  %s\n\n"%(expr, result))
        return result
    return debug_rl
dataset/ETHPy150Open sympy/sympy/sympy/strategies/core.py/debug/original