More Advanced Decorators
Learn how to pass parameters to decorators using nested functions and decorator objects.
We'll cover the following...
With the introduction we've just had, we now know the basics of decorators: what they are and their syntax and semantics. Now we're interested in more advanced uses of decorators that will help us structure our code more cleanly.
We'll see that we can use decorators to separate concerns into smaller functions, and reuse code, but in order to so do effectively, we'd like to parametrize the decorators (otherwise, we'll end up repeating code). For this, we'll explore different options on how to pass arguments to decorators.
Passing arguments to decorators
At this point, we already regard decorators as a powerful tool in Python. However, they would be even more powerful if ...