Decorator
A function returning another function, usually applied as a function transformation using the @wrapper
syntax. Common examples for decorators are classmethod()
and staticmethod()
.
It was inspired in part by Java annotations, and have a similar syntax; the decorator syntax is pure syntactic sugar, using @
as the keyword:
def make_pretty(func):
def inner():
print("I got decorated")
func()
return inner