code: def debug(func):
      
      @wraps(func)
      def wrapped(*args, **kwargs):
          arg = repr(args) + ' ' + repr(kwargs)
          sys.stdout.write('Entering ' + func.__name__ + arg + '\n')
          try:
              result = func(*args, **kwargs)
          except:
              sys.stdout.write('Traceback caught:\n')
              sys.stdout.write(format_exception(*sys.exc_info()))
              raise
          arg = repr(result)
          sys.stdout.write('Leaving ' + func.__name__ + '(): ' + arg + '\n')
          return result
      return wrapped
docs: Decorator that prints a message whenever a function is entered or left.