Meta decorator with parameters, defined in explicit functions

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


Ben Finney <ben+python at benfinney.id.au> 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