Python Decorators: Syntactic Artificial Sweetener
https://nullprogram.com/blog/2019/03/08/ [nullprogram.com]
2019-03-09 07:04
Python has a feature called function decorators. With a little bit of syntax, the behavior of a function or class can be modified in useful ways. Python comes with a few decorators, but most of the useful ones are found in third-party libraries.
The problem is that the Python language reference doesn’t parse an expression after @. It matches a very specific pattern that just so happens to look like a Python expression. It’s not syntactic sugar, it’s syntactic artificial sweetener!