parameters: (fn)
return_statement: return wrapped
docstring: A decorator that prints a function's name, its arguments, and its return
      values each time the function is called. For example,
  
      @trace
      def compute_something(x, y):
          # function body
docstring_summary: A decorator that prints a function's name, its arguments, and its return
      values each time the function is called. For example,
docstring_tokens: A decorator that prints a function s name its arguments and its return values each time the function is called . For example
function: def trace(fn):
      """A decorator that prints a function's name, its arguments, and its return
      values each time the function is called. For example,
  
      @trace
      def compute_something(x, y):
          # function body
      """
      @functools.wraps(fn)
      def wrapped(*args, **kwds):
          global PREFIX
          reprs = [repr(e) for e in args]
          reprs += [repr(k) + '=' + repr(v) for k, v in kwds.items()]
          log('{0}({1})'.format(fn.__name__, ', '.join(reprs)) + ':')
          PREFIX += '    '
          try:
              result = fn(*args, **kwds)
              PREFIX = PREFIX[:-4]
          except Exception as e:
              log(fn.__name__ + ' exited via exception')
              PREFIX = PREFIX[:-4]
              raise
          # Here, print out the return value.
          log('{0}({1}) -> {2}'.format(fn.__name__, ', '.join(reprs), result))
          return result
      return wrapped
function_tokens: def trace ( fn ) : @ functools . wraps ( fn ) def wrapped ( * args , * * kwds ) : global PREFIX reprs = [ repr ( e ) for e in args ] reprs += [ repr ( k ) + '=' + repr ( v ) for k , v in kwds . items ( ) ] log ( '{0}({1})' . format ( fn . __name__ , ', ' . join ( reprs ) ) + ':' ) PREFIX += '    ' try : result = fn ( * args , * * kwds ) PREFIX = PREFIX [ : - 4 ] except Exception as e : log ( fn . __name__ + ' exited via exception' ) PREFIX = PREFIX [ : - 4 ] raise # Here, print out the return value. log ( '{0}({1}) -> {2}' . format ( fn . __name__ , ', ' . join ( reprs ) , result ) ) return result return wrapped