June 2019
Beginner to intermediate
770 pages
19h 24m
English
Sometimes, we need to provide parameters to a decorator. The idea is that we are going to customize the wrapping function. When we do this, decoration becomes a two-step process.
Here's a snippet showing how we provide a parameterized decorator to a function definition:
@decorator(arg)
def func( ):
pass
The implementation is as follows:
def func( ):
pass
func = decorator(arg)(func)
We've done the following three things:
It can help to think of func = decorate(arg)(func) ...
Read now
Unlock full access