by serial_dev · 1y ago · 0 comments
The decorator syntax is purely sugar:
@foo
def bar():
pass
is equivalent to def bar():
pass
bar = foo(bar)
except that `bar` only gets assigned once.It's possible to use metaprogramming to apply the decorator automatically to every function (by iterating over attributes of the module and filtering for functions).