Skip to main content
Python Code Completion Hard +35 XP

Decorator Syntax

Complete the decorator pattern.

PythonFill in the blank
def timer(func):
    def wrapper(*args, **kwargs):
        start = time.time()
        result = func(*args, **kwargs)
        print(f"Took {time.time() - start}s")
        return ___
    return wrapper

Type the missing code

Show answer and explanation

Answer: result

The wrapper must return the original function's result to maintain the same behavior.

Hint: What should the wrapper return?

What this challenge tests

Code Completion in Python: decorators, advanced.

Related challenges