Adding a parameter to a decorator

A common requirement is to customize a decorator with additional parameters. Rather than simply creating a composite Adding a parameter to a decorator, we're doing something a bit more complex. We're creating Adding a parameter to a decorator. We've applied a parameter, c, as part of creating the wrapper. This parameterized composite,Adding a parameter to a decorator, can then be used with the actual data, x.

In Python syntax, we can write it as follows:

@deco(arg)
def func( ):
    something

This will provide a parameterized ...

Get Functional Python Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.