What are decorators in Python?

Decorators are used to add some design pattern to a function without changing its structure. Decorators generally are defined before the function they are enhancing.

To apply a decorator, we first define the decorator function it is applied to and simply add the decorator function above the function it has to be applied to. For this, we use @ symbol before the decorator.

Decorators and Generators in Python

Popular Posts

Spread the knowledge
 
  

Leave a Reply

Your email address will not be published. Required fields are marked *