Python Decorators Made Simple
What are decorators? How to use them? When to use them?
Python decorators provide a way to extend the functionality of a function, method, or class outside of it.
Here is an example of decorating divide
function with functionality to check that the divisor is not 0
.
@zero_guard
def divide(x, y):
return x / y