0 votes
in Python by
What are decorators in Python?

1 Answer

0 votes
by

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:

@my_decorator

def func1():

    pass

Related questions

0 votes
asked Jun 12, 2020 in Python by Robindeniel
0 votes
asked Oct 12, 2021 in Python by rajeshsharma
...