Um decorador em [[Linguagem de programação Python|Python]] é uma função de ordem superior que pode modificar outra função. Por exemplo, vamos escrever um decorador que anuncia quando uma função está prestes a começar e quando termina. Podemos então aplicar este decorador usando um símbolo `@`.
```python
def announce(f):
def wrapper():
print("About to run the function")
f()
print("Done with the function")
return wrapper
@announce
def hello():
print("Hello, World!")
hello()
""" Output:
About to run the function
Hello world!
Done with the function
"""
```
:: **Referência:** :: [Python documentation on decorators](https://peps.python.org/pep-0318/)