def print_args ( output = sys . stdout ) : def decorator ( func ) : """The decorator function.
        """ @ wraps ( func ) def _ ( * args , * * kwargs ) : """The decorated function.
            """ output . write ( "Args: {0}, KwArgs: {1}\n" . format ( str ( args ) , str ( kwargs ) ) ) return func ( * args , * * kwargs ) return _ return decorator
python decorate print funcion
Decorate a function so that print arguments before calling it .
def print_args(output=sys.stdout):
    """Decorate a function so that print arguments before calling it.

    Args:
      output: writable to print args. (Default: sys.stdout)
    """
    def decorator(func):
        """The decorator function.
        """
        @wraps(func)
        def _(*args, **kwargs):
            """The decorated function.
            """
            output.write(
                "Args: {0}, KwArgs: {1}\n".format(str(args), str(kwargs)))
            return func(*args, **kwargs)
        return _
    return decorator