Language Syntax
Decorator — Python syntax
Evaluate decorator expressions when defining a function or class; apply the resulting callables from the bottom up and bind the final result. A decorator can replace the original object.
Formal Syntax & Structure
python syntaxpython
@decorator_expressiondef name(parameters): suiteWorking Example
Example Snippetpython
def wrap(f): return lambda: '['+f()+']'@wrap@wrapdef name(): return 'x'print(name())