Meta decorator with parameters, defined in explicit functions

Paul Rubin at nospam.invalid
Tue Jun 28 02:08:44 EDT 2016

Ben Finney <ben+python at> writes:
>     decorator_with_args = lambda decorator: lambda *args, **kwargs:
> lambda func: decorator(func, *args, **kwargs)
> I would like to see a more Pythonic, more explicit and expressive
> replacement with its component parts easily understood.

How's this:

    from functools import partial
    def dwa(decorator):
        def wrap(*args,**kwargs):
                return partial(decorator, *args, **kwargs)
        return wrap

More information about the Python-list mailing list