3 ms·
It's a decorator, not an annotation. The decorator syntax is purely sugar: @foo def bar(): pass is equivalent to def bar(): pass bar = f
by zahlman 2y ago
It's a decorator, not an annotation.
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).