Python·100 questions

What are decorators?

Answer
A function that modifies another function.
@decorator above a definition.
def log(f): def wrapper(*a): return f(*a); return wrapper.
functools.wraps preserves name/docstring.
Examples: @property, @staticmethod.
Was this answer helpful?

More questions in this topic

Related questions from other topics