enhancing decorator signatures

Diez B. Roggisch deets at nospam.web.de
Wed Aug 6 08:16:09 EDT 2008


Hi,

I'm using Michele S's decorator-module to create decorators with matching
signatures, for better error-catching.

However, I now want to enrich the signature of a generic wrapper so that the
new function will accept more parameters (keyword only). These additional
parameters are consumed by the wrapper and not passed to the decorated
function.

So something like this would be cool:

@enriched_decorator("bar")
def some_decorator(f, **args, **kwargs):
    bar = kwargs.pop("bar")
    return f(**args, **kwargs)

Anybody has done something like this?

Diez



More information about the Python-list mailing list