in Python by (32.2k points)
What are decorators in Python?

1 Answer

0 votes
by (32.2k points)

Decorators in Python are used to modify behaviours of functions. For example, if you want to log all calls to a particular set of functions, cache its parameters and return values, perform benchmarks, etc.

Decorators are prefixed with the @ symbol and placed right before function declaration:


def func1():


Related questions

0 votes
asked Jun 12, 2020 in Python by Robindeniel (20.8k points)
0 votes
asked Oct 12, 2021 in Python by rajeshsharma (23.9k points)
0 votes
asked Sep 22, 2021 in Python by sharadyadav1986 (31.7k points)