<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def tracing(pattern=None, out=None):
 """Print executed lines to stdout."""

    _trace = partial(trace_line, pattern)

    if out is None:
        out = sys.stdout

    with redirect_stdout(out):
        sys.settrace(_trace)
        try:
            yield
        finally:
            sys.settrace(None)