Python - Decorators

Decorators decorate functions. They themselves are functions that accept a function and return a function.

Decorators get applied using a special syntax.

def show_errors():

In the above the decorator is the @suppress_errors statement.

Decorators are important in that they allow a set of common tasks to be performed by many different functions, ususlaly before or after doing something more specific to the target function.

Common areas where decorators get applied include: access control, error handling, caching, logging, mapping routes to functions etc.

Without decorators you would need to copy code several times to perform that task before or after the target function is executed.

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section. This feedback helps us gauge our progress.

Help me Grow.

I set myself some growth ambitions I desire to achieve by this year's end regarding this website and my youtube channel. Am halfway. Help me reach them by:


What do You Think

Previous Post Next Post