Adding a parameter to a decorator
A common requirement is to customize a decorator with additional parameters. Rather than simply creating a composite , we're doing something a bit more complex. We're creating . We've applied a parameter, c, as part of creating the wrapper. This parameterized composite,, 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.