in Python by
Q:

What are decorators in Python?

1 Answer

0 votes
by

Decorators belong most probably to the most beautiful and most powerful design possibilities in Python, but at the same time the concept is considered by many as complicated to get into. To be precise, the usage of decorators is very easy, but writing decorators can be complicated, especially if you are not experienced with decorators and some functional programming concepts.

Even though it is the same underlying concept, we have two different kinds of decorators in Python:

  • Function decorators
  • Class decorators

A decorator in Python is any callable Python object that is used to modify a function or a class. A reference to a function "func" or a class "C" is passed to a decorator and the decorator returns a modified function or class. The modified functions or classes usually contain calls to the original function "func" or class "C".

 

Click here to read more about Python
Click here to read more about Insurance

Related questions

0 votes
asked May 16, 2020 in Python by Robindeniel
0 votes
asked Jan 1 in Python by SakshiSharma
0 votes
asked Aug 30, 2020 in Python by sharadyadav1986
0 votes
asked Jun 30, 2020 in Python by GeorgeBell
0 votes
asked Jun 12, 2020 in Python by Robindeniel
...