Decorators are functions that make other functions better. It's a bit meta, but they're very powerful. In this series of video's we'll explore them by building our own but also by showing how you typically use them.
Functions can accept functions as input.
def apply(func, a, b): return func(a, b) def add(a, b): return a + b def sub(a, b): return a - b apply(add, 1, 2), apply(sub, 1, 2)
But they can also return functions as output.
def power(n): def func(number): return number**n return func pow2 = power(2) pow3 = power(3) pow2(3), pow3(3)
Feedback? See an issue? Something unclear? Feel free to mention it here.
If you want to be kept up to date, consider signing up for the newsletter.