← All practice pages

Python

Python Decorators

A decorator wraps a function to add behaviour — timing, retries, logging — without editing the function itself. You apply one with the @ syntax.

Try it now

Write a decorator "@timer" that measures and prints how long the wrapped function takes to run, then returns the function result unchanged.

Create a free account to run your answer and get ARIA's review.