
Functional Python Programming
By :

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 deco(arg)
function to the base function definition.
The effect is as follows:
def func( ): something func= deco(arg)(func)
We've done three things and they are as follows:
Define a function, func.
Apply the abstract decorator, deco()
, to its arguments to create a concrete decorator, deco(arg).
Apply the concrete decorator, deco(arg)
, to the base function to create the decorated version of the function, deco(arg)(func).
A decorator with arguments involves indirect construction of the final function. We seem to have moved beyond merely...
Change the font size
Change margin width
Change background colour