April 2014
Beginner to intermediate
634 pages
15h 22m
English
Sometimes we want to provide more elaborate 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.
When we write the following code, we provide a parameterized decorator to a function definition:
@decorator(arg)
def func( ):
passThe use of the decorator is a shorthand for the following code:
def func( ):
pass
func= decorator(arg)(func)Both examples do the following three things:
funcdecorator(arg)decorator(arg)(func)This means that ...